Mercurial > hg > orthanc
comparison OrthancFramework/Resources/CMake/Compiler.cmake @ 4063:e00f3d089991 framework
shared library of orthanc framework
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 11 Jun 2020 16:40:34 +0200 |
parents | 9c37896a4457 |
children | 3a59a021b5de |
comparison
equal
deleted
inserted
replaced
4062:0953b3dc3261 | 4063:e00f3d089991 |
---|---|
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 |
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(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() |