Debian Codegraph @

Tests/RunCMake/SharedLibraryDefines/common.cmake

raw
1 enable_language(${language})
2
3 function(sharedLibraryDefs_addTests policy_value)
4 block(SCOPE_FOR POLICIES)
5 if (NOT "${policy_value}" STREQUAL "WARN")
6 # WARN is the default value - no need to set it
7 cmake_policy(SET CMP0203 "${policy_value}")
8 endif()
9
10 add_executable(${language}-CMP0203_${policy_value} checker.${extension})
11 target_compile_definitions(${language}-CMP0203_${policy_value} PRIVATE "FUNCTION=main")
12
13 add_library(${language}-CMP0203_${policy_value}_shared SHARED checker.${extension})
14 target_compile_definitions(${language}-CMP0203_${policy_value}_shared PRIVATE "FUNCTION=test")
15
16 add_library(${language}-CMP0203_${policy_value}_static STATIC checker.${extension})
17 target_compile_definitions(${language}-CMP0203_${policy_value}_static PRIVATE "FUNCTION=test")
18 endblock()
19 endfunction()
20
21 sharedLibraryDefs_addTests(OLD)
22 sharedLibraryDefs_addTests(WARN)
23
24 if (CMAKE_GENERATOR MATCHES "Visual Studio")
25 # Visual Studio always defines `_WINDLL`
26 target_compile_definitions(${language}-CMP0203_OLD_shared PRIVATE "MUST_HAVE_DEFINE")
27 target_compile_definitions(${language}-CMP0203_WARN_shared PRIVATE "MUST_HAVE_DEFINE")
28 endif()
29
30 sharedLibraryDefs_addTests(NEW)
31
32 if ("${CMAKE_${language}_COMPILER_ID}" STREQUAL "MSVC" OR "${CMAKE_${language}_SIMULATE_ID}" STREQUAL "MSVC")
33 target_compile_definitions(${language}-CMP0203_NEW_shared PRIVATE "MUST_HAVE_DEFINE")
34 endif()