Mercurial > hg > orthanc-webviewer
comparison Resources/Orthanc/CMake/Compiler.cmake @ 272:2c3555b8eabc
sync
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 01 Jul 2020 11:29:01 +0200 |
parents | 938257eebc03 |
children | 52b56343d268 |
comparison
equal
deleted
inserted
replaced
270:3e9307f6da67 | 272:2c3555b8eabc |
---|---|
1 # This file sets all the compiler-related flags | 1 # This file sets all the compiler-related flags |
2 | |
3 | |
4 # Save the current compiler flags to the cache every time cmake configures the project | |
5 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}" CACHE STRING "compiler flags" FORCE) | |
6 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}" CACHE STRING "compiler flags" FORCE) | |
7 | |
2 | 8 |
3 include(CheckLibraryExists) | 9 include(CheckLibraryExists) |
4 | 10 |
5 if ((CMAKE_CROSSCOMPILING AND NOT | 11 if ((CMAKE_CROSSCOMPILING AND NOT |
6 "${CMAKE_SYSTEM_VERSION}" STREQUAL "CrossToolNg") OR | 12 "${CMAKE_SYSTEM_VERSION}" STREQUAL "CrossToolNg") OR |
73 # 1600), Microsoft ships a standard-compliant <stdint.h> | 79 # 1600), Microsoft ships a standard-compliant <stdint.h> |
74 # header. For earlier versions of Visual Studio, give access to a | 80 # header. For earlier versions of Visual Studio, give access to a |
75 # compatibility header. | 81 # compatibility header. |
76 # http://stackoverflow.com/a/70630/881731 | 82 # http://stackoverflow.com/a/70630/881731 |
77 # https://en.wikibooks.org/wiki/C_Programming/C_Reference/stdint.h#External_links | 83 # https://en.wikibooks.org/wiki/C_Programming/C_Reference/stdint.h#External_links |
78 include_directories(${ORTHANC_ROOT}/Resources/ThirdParty/VisualStudio) | 84 include_directories(${CMAKE_CURRENT_LIST_DIR}/../../Resources/ThirdParty/VisualStudio) |
79 endif() | 85 endif() |
80 | 86 |
81 link_libraries(netapi32) | 87 link_libraries(netapi32) |
82 endif() | 88 endif() |
83 | 89 |
107 set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--no-undefined") | 113 set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--no-undefined") |
108 endif() | 114 endif() |
109 | 115 |
110 if (NOT DEFINED ENABLE_PLUGINS_VERSION_SCRIPT OR | 116 if (NOT DEFINED ENABLE_PLUGINS_VERSION_SCRIPT OR |
111 ENABLE_PLUGINS_VERSION_SCRIPT) | 117 ENABLE_PLUGINS_VERSION_SCRIPT) |
112 set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--version-script=${ORTHANC_ROOT}/Plugins/Samples/Common/VersionScript.map") | 118 set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--version-script=${CMAKE_CURRENT_LIST_DIR}/../VersionScriptPlugins.map") |
113 endif() | 119 endif() |
114 | 120 |
115 # Remove the "-rdynamic" option | 121 # Remove the "-rdynamic" option |
116 # http://www.mail-archive.com/cmake@cmake.org/msg08837.html | 122 # http://www.mail-archive.com/cmake@cmake.org/msg08837.html |
117 set(CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS "") | 123 set(CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS "") |
195 add_definitions(-DHAVE_WIN_PTHREAD=0) | 201 add_definitions(-DHAVE_WIN_PTHREAD=0) |
196 endif() | 202 endif() |
197 endif() | 203 endif() |
198 | 204 |
199 elseif (${CMAKE_SYSTEM_NAME} STREQUAL "Darwin") | 205 elseif (${CMAKE_SYSTEM_NAME} STREQUAL "Darwin") |
200 SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -exported_symbols_list ${ORTHANC_ROOT}/Plugins/Samples/Common/ExportedSymbols.list") | 206 SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -exported_symbols_list ${CMAKE_CURRENT_LIST_DIR}/../ExportedSymbolsPlugins.list") |
201 | 207 |
202 add_definitions( | 208 add_definitions( |
203 -D_XOPEN_SOURCE=1 | 209 -D_XOPEN_SOURCE=1 |
204 ) | 210 ) |
205 link_libraries(iconv) | 211 link_libraries(iconv) |
206 | 212 |
207 elseif (CMAKE_SYSTEM_NAME STREQUAL "Emscripten") | 213 elseif (CMAKE_SYSTEM_NAME STREQUAL "Emscripten") |
208 message("Building using Emscripten (for WebAssembly or asm.js targets)") | 214 message("Building using Emscripten (for WebAssembly or asm.js targets)") |
209 | 215 include(${CMAKE_CURRENT_LIST_DIR}/EmscriptenParameters.cmake) |
210 # The BINARYEN_TRAP_MODE specifies what to do when divisions per | |
211 # zero (and similar conditions like integer overflows) are | |
212 # encountered: The "clamp" mode avoids throwing errors, as they | |
213 # cannot be properly catched by "try {} catch (...)" constructions. | |
214 # Setting this option to "ON" fixes error: "shared:ERROR: | |
215 # BINARYEN_TRAP_MODE is not supported by the LLVM wasm backend" if | |
216 # using the "upstream" backend of Emscripten. | |
217 if (NOT EMSCRIPTEN_SET_LLVM_WASM_BACKEND) | |
218 set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -s BINARYEN_TRAP_MODE='\"clamp\"'") | |
219 endif() | |
220 | |
221 set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -s EXTRA_EXPORTED_RUNTIME_METHODS='[\"ccall\", \"cwrap\"]'") | |
222 | 216 |
223 elseif (CMAKE_SYSTEM_NAME STREQUAL "Android") | 217 elseif (CMAKE_SYSTEM_NAME STREQUAL "Android") |
224 | 218 |
225 else() | 219 else() |
226 message("Unknown target platform: ${CMAKE_SYSTEM_NAME}") | 220 message("Unknown target platform: ${CMAKE_SYSTEM_NAME}") |
252 # will invoke "ar" several times with several batches of ".o" | 246 # will invoke "ar" several times with several batches of ".o" |
253 # objects, and using "r" would overwrite symbols defined in | 247 # objects, and using "r" would overwrite symbols defined in |
254 # preceding batches. https://cmake.org/Bug/view.php?id=14874 | 248 # preceding batches. https://cmake.org/Bug/view.php?id=14874 |
255 set(CMAKE_CXX_ARCHIVE_APPEND "<CMAKE_AR> <LINK_FLAGS> q <TARGET> <OBJECTS>") | 249 set(CMAKE_CXX_ARCHIVE_APPEND "<CMAKE_AR> <LINK_FLAGS> q <TARGET> <OBJECTS>") |
256 endif() | 250 endif() |
257 | |
258 | |
259 if (STATIC_BUILD) | |
260 add_definitions(-DORTHANC_STATIC=1) | |
261 else() | |
262 add_definitions(-DORTHANC_STATIC=0) | |
263 endif() |