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