*/}}

CMakeLists.txt 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. cmake_minimum_required(VERSION 3.1)
  2. project(demo)
  3. set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR})
  4. find_package(lagui REQUIRED)
  5. find_package(PNG REQUIRED)
  6. find_package(LuaJIT)
  7. add_compile_options("$<$<C_COMPILER_ID:MSVC>:/utf-8>")
  8. add_compile_options("$<$<CXX_COMPILER_ID:MSVC>:/utf-8>")
  9. include_directories(
  10. ${LAGUI_INCLUDE_DIRS_ALL}
  11. )
  12. if(LUAJIT_FOUND)
  13. include_directories(${LUA_INCLUDE_DIR})
  14. endif()
  15. add_definitions(-w)
  16. set(SimplestFiles ${CMAKE_SOURCE_DIR}/simplest.c)
  17. set(OperatorFiles ${CMAKE_SOURCE_DIR}/operator.c)
  18. set(SimplePropertiesFiles ${CMAKE_SOURCE_DIR}/simple_properties.c)
  19. set(WidgetsFiles ${CMAKE_SOURCE_DIR}/widgets.c)
  20. set(WidgetFlagsFiles ${CMAKE_SOURCE_DIR}/widget_flags.c)
  21. set(FruitsFiles ${CMAKE_SOURCE_DIR}/fruits.c)
  22. set(ModellingFiles ${CMAKE_SOURCE_DIR}/modelling_main.c)
  23. set(CalculatorFiles ${CMAKE_SOURCE_DIR}/calculator.c)
  24. set(NVGTestFiles ${CMAKE_SOURCE_DIR}/nvgtest.c)
  25. if(LUAJIT_FOUND)
  26. set(LuajitFiles ${CMAKE_SOURCE_DIR}/luajit.c)
  27. endif()
  28. set(ExampleViewerFiles ${CMAKE_SOURCE_DIR}/example_viewer.c)
  29. add_executable(simplest ${SimplestFiles})
  30. add_executable(operator ${OperatorFiles})
  31. add_executable(simple_properties ${SimplePropertiesFiles})
  32. add_executable(widgets ${WidgetsFiles})
  33. add_executable(widget_flags ${WidgetFlagsFiles})
  34. add_executable(fruits ${FruitsFiles})
  35. add_executable(modelling_main ${ModellingFiles})
  36. add_executable(calculator ${CalculatorFiles})
  37. add_executable(nvgtest ${NVGTestFiles})
  38. if(LUAJIT_FOUND)
  39. add_executable(luajit ${LuajitFiles})
  40. endif()
  41. add_executable(example_viewer ${ExampleViewerFiles})
  42. target_link_libraries(simplest ${LAGUI_SHARED_LIBS} )
  43. target_link_libraries(operator ${LAGUI_SHARED_LIBS} )
  44. target_link_libraries(simple_properties ${LAGUI_SHARED_LIBS} )
  45. target_link_libraries(widgets ${LAGUI_SHARED_LIBS} )
  46. target_link_libraries(widget_flags ${LAGUI_SHARED_LIBS} )
  47. target_link_libraries(fruits ${LAGUI_SHARED_LIBS} )
  48. target_link_libraries(modelling_main ${LAGUI_SHARED_LIBS} )
  49. target_link_libraries(calculator ${LAGUI_SHARED_LIBS} )
  50. target_link_libraries(nvgtest ${LAGUI_SHARED_LIBS} )
  51. if(LUAJIT_FOUND)
  52. target_link_libraries(luajit ${LAGUI_SHARED_LIBS} ${LUA_LIBRARY})
  53. endif()
  54. target_link_libraries(example_viewer ${LAGUI_SHARED_LIBS} )
  55. message("${LAGUI_SHARED_LIBS}")
  56. target_link_options(simplest PUBLIC "-Wl,--start-group")
  57. target_link_options(operator PUBLIC "-Wl,--start-group")
  58. target_link_options(simple_properties PUBLIC "-Wl,--start-group")
  59. target_link_options(widgets PUBLIC "-Wl,--start-group")
  60. target_link_options(widget_flags PUBLIC "-Wl,--start-group")
  61. target_link_options(fruits PUBLIC "-Wl,--start-group")
  62. target_link_options(modelling_main PUBLIC "-Wl,--start-group")
  63. target_link_options(calculator PUBLIC "-Wl,--start-group")
  64. target_link_options(nvgtest PUBLIC "-Wl,--start-group")
  65. target_link_options(luajit PUBLIC "-Wl,--start-group")
  66. target_link_options(example_viewer PUBLIC "-Wl,--start-group")
  67. get_property(GENERATOR_IS_MULTI_CONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
  68. if(GENERATOR_IS_MULTI_CONFIG)
  69. set(INSTALL_CONFIG_PATH ${CMAKE_CURRENT_BINARY_DIR}/$<CONFIG>)
  70. else()
  71. set(INSTALL_CONFIG_PATH ${CMAKE_CURRENT_BINARY_DIR})
  72. endif()
  73. add_custom_command(
  74. TARGET example_viewer POST_BUILD
  75. COMMAND ${CMAKE_COMMAND} -E make_directory ${INSTALL_CONFIG_PATH}/example_source_files
  76. COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/luajit.c ${INSTALL_CONFIG_PATH}/example_source_files/luajit.c
  77. COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/nvgtest.c ${INSTALL_CONFIG_PATH}/example_source_files/nvgtest.c
  78. COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/calculator.c ${INSTALL_CONFIG_PATH}/example_source_files/calculator.c
  79. COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/widgets.c ${INSTALL_CONFIG_PATH}/example_source_files/widgets.c
  80. COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/widget_flags.c ${INSTALL_CONFIG_PATH}/example_source_files/widget_flags.c
  81. COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/fruits.c ${INSTALL_CONFIG_PATH}/example_source_files/fruits.c
  82. COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/modelling_main.c ${INSTALL_CONFIG_PATH}/example_source_files/modelling_main.c
  83. COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/simple_properties.c ${INSTALL_CONFIG_PATH}/example_source_files/simple_properties.c
  84. COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/operator.c ${INSTALL_CONFIG_PATH}/example_source_files/operator.c
  85. COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/simplest.c ${INSTALL_CONFIG_PATH}/example_source_files/simplest.c
  86. )