CMakeLists.txt 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. cmake_minimum_required(VERSION 2.6)
  2. project(ModuleDefinition C)
  3. # Test .def file source recognition for DLLs.
  4. add_library(example_dll SHARED example_dll.c example_dll.def)
  5. add_library(split_dll SHARED split_dll.c split_dll_1.def split_dll_2.def)
  6. # Test generated .def file.
  7. add_custom_command(OUTPUT example_dll_gen.def
  8. DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/example_dll_gen.def.in
  9. COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/example_dll_gen.def.in
  10. ${CMAKE_CURRENT_BINARY_DIR}/example_dll_gen.def
  11. )
  12. add_library(example_dll_gen SHARED example_dll_gen.c example_dll_gen.def)
  13. # Test /DEF:<file> flag recognition for VS.
  14. if(MSVC OR CMAKE_C_COMPILER_ID STREQUAL "Intel")
  15. add_library(example_dll_2 SHARED example_dll_2.c)
  16. set_property(TARGET example_dll_2 PROPERTY LINK_FLAGS
  17. /DEF:"${ModuleDefinition_SOURCE_DIR}/example_dll_2.def")
  18. set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS EXAMPLE_DLL_2)
  19. set(example_dll_2 example_dll_2)
  20. endif()
  21. # Test .def file source recognition for EXEs.
  22. add_executable(example_exe example_exe.c example_exe.def)
  23. set_property(TARGET example_exe PROPERTY ENABLE_EXPORTS 1)
  24. target_link_libraries(example_exe
  25. example_dll
  26. example_dll_gen
  27. ${example_dll_2}
  28. split_dll
  29. )
  30. # Test linking to the executable.
  31. add_library(example_mod_1 MODULE example_mod_1.c)
  32. target_link_libraries(example_mod_1 example_exe example_dll ${example_dll_2})