CMakeLists.txt 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. cmake_minimum_required(VERSION 2.8.4)
  2. project(VSResource)
  3. string(REPLACE "/INCREMENTAL:YES" ""
  4. CMAKE_EXE_LINKER_FLAGS_DEBUG
  5. "${CMAKE_EXE_LINKER_FLAGS_DEBUG}")
  6. message(STATUS "CMAKE_RC_COMPILER='${CMAKE_RC_COMPILER}'")
  7. # Because of the following avoidance techniques required for windres and VS6,
  8. # we recommend using a configured header file, and defining preprocessor
  9. # symbols via #define code and including that header in the rc file. Using
  10. # add_definitions is fine for simple definitions (with no spaces and no
  11. # quoting), but requires avoidance or work-arounds beyond that...
  12. if(CMAKE_RC_COMPILER MATCHES windres)
  13. # windres rc compiler does not properly define quoted /D values as strings
  14. message(STATUS "CMAKE_RC_COMPILER MATCHES windres")
  15. add_definitions(/DCMAKE_RCDEFINE=test.txt)
  16. add_definitions(/DCMAKE_RCDEFINE_NO_QUOTED_STRINGS)
  17. if(MSYS AND CMAKE_CURRENT_BINARY_DIR MATCHES " ")
  18. # windres cannot handle spaces in include dir, and
  19. # for the MSys shell we do not convert to shortpath.
  20. set(CMAKE_RC_NO_INCLUDE 1)
  21. endif()
  22. elseif(MSVC60)
  23. # VS6 rc compiler does not deal well with spaces in a "/D" value, but it can
  24. # handle the quoting
  25. message(STATUS "MSVC60")
  26. add_definitions(/DCMAKE_RCDEFINE="test.txt")
  27. else()
  28. # expected case -- rc compiler is "capable enough"
  29. message(STATUS
  30. "rc compiler handles quoted strings with spaces in values via /D")
  31. set(TEXTFILE_FROM_SOURCE_DIR "textfile, spaces in name, from binary dir")
  32. configure_file(${CMAKE_CURRENT_SOURCE_DIR}/test.txt
  33. "${CMAKE_CURRENT_BINARY_DIR}/test with spaces.txt" @ONLY)
  34. add_definitions(/DCMAKE_RCDEFINE="test with spaces.txt")
  35. endif()
  36. if(CMAKE_RC_NO_INCLUDE)
  37. add_definitions(/DCMAKE_RC_NO_INCLUDE)
  38. else()
  39. configure_file(${CMAKE_CURRENT_SOURCE_DIR}/include.rc.in
  40. "${CMAKE_CURRENT_BINARY_DIR}/include.rc" @ONLY)
  41. include_directories(${CMAKE_CURRENT_BINARY_DIR})
  42. endif()
  43. add_executable(VSResource main.cpp test.rc)
  44. set_property(TARGET VSResource
  45. PROPERTY VS_GLOBAL_CMakeTestVsGlobalVariable "test val")