|
1 | | -add_library(cae-compile-options INTERFACE) |
| 1 | +set(TARGET_NAME "${TARGET_NAME}") |
2 | 2 |
|
3 | | -target_compile_features(cae-compile-options INTERFACE cxx_std_23) |
| 3 | +add_library(${TARGET_NAME} INTERFACE) |
| 4 | + |
| 5 | +target_compile_features(${TARGET_NAME} INTERFACE cxx_std_23) |
4 | 6 |
|
5 | 7 | option(CAE_STRICT_WARNINGS "Enable strict warning level" OFF) |
6 | 8 | option(CAE_ENABLE_SANITIZERS "Enable address and undefined sanitizers" OFF) |
7 | 9 | option(CAE_ENABLE_LTO "Enable LTO on final targets" OFF) |
8 | 10 |
|
9 | | -target_compile_options(cae-compile-options INTERFACE |
| 11 | +target_compile_options(${TARGET_NAME} INTERFACE |
10 | 12 | # Strict warnings |
11 | 13 | $<$<AND:$<CXX_COMPILER_ID:GNU,Clang,AppleClang>,$<BOOL:${CAE_STRICT_WARNINGS}>,$<NOT:$<PLATFORM_ID:Android,Emscripten,iOS>>>: |
12 | 14 | -Wall |
@@ -45,68 +47,68 @@ target_compile_options(cae-compile-options INTERFACE |
45 | 47 | ) |
46 | 48 |
|
47 | 49 | # GCC / Clang |
48 | | -target_compile_options(cae-compile-options INTERFACE |
| 50 | +target_compile_options(${TARGET_NAME} INTERFACE |
49 | 51 | $<$<AND:$<CONFIG:RelWithDebInfo>,$<CXX_COMPILER_ID:GNU,Clang,AppleClang>>:-O2> |
50 | 52 | $<$<AND:$<CONFIG:Debug>,$<CXX_COMPILER_ID:GNU,Clang,AppleClang>>:-O0 -g> |
51 | 53 | ) |
52 | 54 |
|
53 | 55 | # MSVC |
54 | | -target_compile_options(cae-compile-options INTERFACE |
| 56 | +target_compile_options(${TARGET_NAME} INTERFACE |
55 | 57 | $<$<AND:$<CONFIG:Release>,$<CXX_COMPILER_ID:MSVC>>:/O2> |
56 | 58 | $<$<AND:$<CONFIG:RelWithDebInfo>,$<CXX_COMPILER_ID:MSVC>>:/O2 /Zi> |
57 | 59 | $<$<AND:$<CONFIG:Debug>,$<CXX_COMPILER_ID:MSVC>>:/Od /Zi> |
58 | 60 | ) |
59 | 61 |
|
60 | | -target_compile_definitions(cae-compile-options INTERFACE |
| 62 | +target_compile_definitions(${TARGET_NAME} INTERFACE |
61 | 63 | $<$<CONFIG:Debug>: |
62 | 64 | CAE_DEBUG |
63 | 65 | > |
64 | 66 | ) |
65 | 67 |
|
66 | 68 | if(CAE_ENABLE_SANITIZERS) |
67 | | - target_compile_options(cae-compile-options INTERFACE |
| 69 | + target_compile_options(${TARGET_NAME} INTERFACE |
68 | 70 | $<$<AND:$<CXX_COMPILER_ID:GNU,Clang>,$<NOT:$<PLATFORM_ID:Android,Emscripten,Windows>>>: |
69 | 71 | -fsanitize=address,undefined |
70 | 72 | > |
71 | 73 | ) |
72 | | - target_link_options(cae-compile-options INTERFACE |
| 74 | + target_link_options(${TARGET_NAME} INTERFACE |
73 | 75 | $<$<AND:$<CXX_COMPILER_ID:GNU,Clang>,$<NOT:$<PLATFORM_ID:Android,Emscripten,Windows>>>: |
74 | 76 | -fsanitize=address,undefined |
75 | 77 | > |
76 | 78 | ) |
77 | 79 | endif() |
78 | 80 |
|
79 | | -function(cae_enable_lto target) |
| 81 | +function(cae_enable_lto TARGET) |
80 | 82 | if (CAE_ENABLE_LTO) |
81 | 83 | include(CheckIPOSupported) |
82 | 84 | check_ipo_supported(RESULT CAE_LTO_SUPPORTED OUTPUT CAE_LTO_ERROR) |
83 | 85 | if (CAE_LTO_SUPPORTED) |
84 | | - set_property(TARGET ${target} PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE) |
| 86 | + set_property(TARGET ${TARGET} PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE) |
85 | 87 | else() |
86 | 88 | message(WARNING "CAE: LTO not supported: ${CAE_LTO_ERROR}") |
87 | 89 | endif() |
88 | 90 | endif() |
89 | 91 | endfunction() |
90 | 92 |
|
91 | 93 | if (EMSCRIPTEN) |
92 | | - target_compile_definitions(cae-compile-options INTERFACE |
| 94 | + target_compile_definitions(${TARGET_NAME} INTERFACE |
93 | 95 | CAE_PLATFORM_WEB |
94 | 96 | ) |
95 | 97 | elseif (ANDROID) |
96 | | - target_compile_definitions(cae-compile-options INTERFACE CAE_PLATFORM_ANDROID) |
| 98 | + target_compile_definitions(${TARGET_NAME} INTERFACE CAE_PLATFORM_ANDROID) |
97 | 99 | elseif (APPLE) |
98 | 100 | if (IOS) |
99 | | - target_compile_definitions(cae-compile-options INTERFACE CAE_PLATFORM_IOS) |
| 101 | + target_compile_definitions(${TARGET_NAME} INTERFACE CAE_PLATFORM_IOS) |
100 | 102 | else() |
101 | | - target_compile_definitions(cae-compile-options INTERFACE CAE_PLATFORM_MACOS) |
| 103 | + target_compile_definitions(${TARGET_NAME} INTERFACE CAE_PLATFORM_MACOS) |
102 | 104 | endif() |
103 | 105 | elseif (WIN32) |
104 | | - target_compile_definitions(cae-compile-options INTERFACE |
| 106 | + target_compile_definitions(${TARGET_NAME} INTERFACE |
105 | 107 | CAE_PLATFORM_WINDOWS |
106 | 108 | NOMINMAX |
107 | 109 | WIN32_LEAN_AND_MEAN |
108 | 110 | ) |
109 | 111 | elseif (UNIX) |
110 | | - target_compile_definitions(cae-compile-options INTERFACE CAE_PLATFORM_LINUX) |
| 112 | + target_compile_definitions(${TARGET_NAME} INTERFACE CAE_PLATFORM_LINUX) |
111 | 113 | endif() |
112 | 114 |
|
0 commit comments