windows.cmake 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. set(platform_common_sources windows.c printing.c)
  2. set(platform_gui_libs
  3. user32.lib gdi32.lib comctl32.lib comdlg32.lib winspool.lib)
  4. set(platform_libs)
  5. add_compile_definitions(_CRT_SECURE_NO_WARNINGS)
  6. if(CMAKE_C_COMPILER_ID MATCHES "MSVC")
  7. # Turn off some warnings that I've just found too noisy.
  8. #
  9. # - 4244, 4267: "possible loss of data" when narrowing an integer
  10. # type (separate warning numbers for initialisers and
  11. # assignments). Every time I spot-check instances of this, they
  12. # turn out to be sensible (e.g. something was already checked, or
  13. # was assigned from a previous variable that must have been in
  14. # range). I don't think putting a warning-suppression idiom at
  15. # every one of these sites would improve code legibility.
  16. #
  17. # - 4018: "signed/unsigned mismatch" in integer comparison. Again,
  18. # comes up a lot, and generally my spot checks make it look as if
  19. # it's OK.
  20. #
  21. # - 4146: applying unary '-' to an unsigned type. This happens once,
  22. # in Untangle, and it's on purpose - but I haven't found any idiom
  23. # at the point of use that reassures the compiler that I meant it.
  24. #
  25. # - 4305: truncation from double to float. We use float all the time
  26. # in this code base, and truncations from double are fine.
  27. set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} \
  28. /wd4244 /wd4267 /wd4018 /wd4146 /wd4305")
  29. endif()
  30. function(get_platform_puzzle_extra_source_files OUTVAR NAME)
  31. set(${OUTVAR} ${CMAKE_SOURCE_DIR}/puzzles.rc PARENT_SCOPE)
  32. endfunction()
  33. function(set_platform_gui_target_properties TARGET)
  34. set_target_properties(${TARGET} PROPERTIES WIN32_EXECUTABLE ON)
  35. endfunction()
  36. function(set_platform_puzzle_target_properties NAME TARGET)
  37. if(DEFINED ICO_DIR AND EXISTS ${ICO_DIR}/${NAME}.ico)
  38. target_compile_definitions(${TARGET} PRIVATE ICON_FILE=\"${ICO_DIR}/${NAME}.ico\")
  39. endif()
  40. endfunction()
  41. function(build_platform_extras)
  42. write_generated_games_header()
  43. file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/gamedesc.txt "")
  44. list(SORT puzzle_names)
  45. foreach(name ${puzzle_names})
  46. file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/gamedesc.txt "\
  47. ${name}:\
  48. ${exename_${name}}.exe:\
  49. ${displayname_${name}}:\
  50. ${description_${name}}:\
  51. ${objective_${name}}\n")
  52. endforeach()
  53. add_executable(puzzles windows.c list.c ${puzzle_sources})
  54. target_compile_definitions(puzzles PRIVATE COMBINED)
  55. target_include_directories(puzzles PRIVATE ${generated_include_dir})
  56. target_link_libraries(puzzles common ${platform_gui_libs} ${platform_libs})
  57. set_target_properties(puzzles PROPERTIES WIN32_EXECUTABLE ON)
  58. endfunction()