CMakeLists.txt 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. # The Flutter tooling requires that developers have a version of Visual Studio
  2. # installed that includes CMake 3.14 or later. You should not increase this
  3. # version, as doing so will cause the plugin to fail to compile for some
  4. # customers of the plugin.
  5. cmake_minimum_required(VERSION 3.14)
  6. # Project-level configuration.
  7. set(PROJECT_NAME "wl_base_help")
  8. project(${PROJECT_NAME} LANGUAGES CXX)
  9. # Explicitly opt in to modern CMake behaviors to avoid warnings with recent
  10. # versions of CMake.
  11. cmake_policy(VERSION 3.14...3.25)
  12. # This value is used when generating builds using this plugin, so it must
  13. # not be changed
  14. set(PLUGIN_NAME "wl_base_help_plugin")
  15. # Any new source files that you add to the plugin should be added here.
  16. list(APPEND PLUGIN_SOURCES
  17. "wl_base_help_plugin.cpp"
  18. "wl_base_help_plugin.h"
  19. )
  20. # Define the plugin library target. Its name must not be changed (see comment
  21. # on PLUGIN_NAME above).
  22. add_library(${PLUGIN_NAME} SHARED
  23. "include/wl_base_help/wl_base_help_plugin_c_api.h"
  24. "wl_base_help_plugin_c_api.cpp"
  25. ${PLUGIN_SOURCES}
  26. )
  27. # Apply a standard set of build settings that are configured in the
  28. # application-level CMakeLists.txt. This can be removed for plugins that want
  29. # full control over build settings.
  30. apply_standard_settings(${PLUGIN_NAME})
  31. # Symbols are hidden by default to reduce the chance of accidental conflicts
  32. # between plugins. This should not be removed; any symbols that should be
  33. # exported should be explicitly exported with the FLUTTER_PLUGIN_EXPORT macro.
  34. set_target_properties(${PLUGIN_NAME} PROPERTIES
  35. CXX_VISIBILITY_PRESET hidden)
  36. target_compile_definitions(${PLUGIN_NAME} PRIVATE FLUTTER_PLUGIN_IMPL)
  37. # Source include directories and library dependencies. Add any plugin-specific
  38. # dependencies here.
  39. target_include_directories(${PLUGIN_NAME} INTERFACE
  40. "${CMAKE_CURRENT_SOURCE_DIR}/include")
  41. target_link_libraries(${PLUGIN_NAME} PRIVATE flutter flutter_wrapper_plugin)
  42. # List of absolute paths to libraries that should be bundled with the plugin.
  43. # This list could contain prebuilt libraries, or libraries created by an
  44. # external build triggered from this build file.
  45. set(wl_base_help_bundled_libraries
  46. ""
  47. PARENT_SCOPE
  48. )
  49. ## === Tests ===
  50. ## These unit tests can be run from a terminal after building the example, or
  51. ## from Visual Studio after opening the generated solution file.
  52. #
  53. ## Only enable test builds when building the example (which sets this variable)
  54. ## so that plugin clients aren't building the tests.
  55. #if (${include_${PROJECT_NAME}_tests})
  56. #set(TEST_RUNNER "${PROJECT_NAME}_test")
  57. #enable_testing()
  58. #
  59. ## Add the Google Test dependency.
  60. #include(FetchContent)
  61. #FetchContent_Declare(
  62. # googletest
  63. # URL https://github.com/google/googletest/archive/release-1.11.0.zip
  64. #)
  65. ## Prevent overriding the parent project's compiler/linker settings
  66. #set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
  67. ## Disable install commands for gtest so it doesn't end up in the bundle.
  68. #set(INSTALL_GTEST OFF CACHE BOOL "Disable installation of googletest" FORCE)
  69. #FetchContent_MakeAvailable(googletest)
  70. #
  71. ## The plugin's C API is not very useful for unit testing, so build the sources
  72. ## directly into the test binary rather than using the DLL.
  73. #add_executable(${TEST_RUNNER}
  74. # test/wl_base_help_plugin_test.cpp
  75. # ${PLUGIN_SOURCES}
  76. #)
  77. #apply_standard_settings(${TEST_RUNNER})
  78. #target_include_directories(${TEST_RUNNER} PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}")
  79. #target_link_libraries(${TEST_RUNNER} PRIVATE flutter_wrapper_plugin)
  80. #target_link_libraries(${TEST_RUNNER} PRIVATE gtest_main gmock)
  81. ## flutter_wrapper_plugin has link dependencies on the Flutter DLL.
  82. #add_custom_command(TARGET ${TEST_RUNNER} POST_BUILD
  83. # COMMAND ${CMAKE_COMMAND} -E copy_if_different
  84. # "${FLUTTER_LIBRARY}" $<TARGET_FILE_DIR:${TEST_RUNNER}>
  85. #)
  86. #
  87. ## Enable automatic test discovery.
  88. #include(GoogleTest)
  89. #gtest_discover_tests(${TEST_RUNNER})
  90. #endif()