*/}}

CMakeLists.txt 4.6 KB

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