Mercurial > hg > orthanc-webviewer
comparison Orthanc/Resources/CMake/Compiler.cmake @ 175:dd1ad819ca33
sync
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 04 Jan 2018 07:34:54 +0100 |
parents | 330ecfd96aec |
children | 8fe42ddf0807 |
comparison
equal
deleted
inserted
replaced
174:81f16c5667ba | 175:dd1ad819ca33 |
---|---|
1 # This file sets all the compiler-related flags | 1 # This file sets all the compiler-related flags |
2 | 2 |
3 if (CMAKE_CROSSCOMPILING) | 3 if (CMAKE_CROSSCOMPILING OR |
4 "${CMAKE_SYSTEM_VERSION}" STREQUAL "LinuxStandardBase") | |
4 # Cross-compilation necessarily implies standalone and static build | 5 # Cross-compilation necessarily implies standalone and static build |
5 SET(STATIC_BUILD ON) | 6 SET(STATIC_BUILD ON) |
6 SET(STANDALONE_BUILD ON) | 7 SET(STANDALONE_BUILD ON) |
7 endif() | 8 endif() |
8 | 9 |
85 endif() | 86 endif() |
86 | 87 |
87 # Remove the "-rdynamic" option | 88 # Remove the "-rdynamic" option |
88 # http://www.mail-archive.com/cmake@cmake.org/msg08837.html | 89 # http://www.mail-archive.com/cmake@cmake.org/msg08837.html |
89 set(CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS "") | 90 set(CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS "") |
90 link_libraries(uuid pthread) | 91 link_libraries(pthread) |
91 | 92 |
92 if (NOT ${CMAKE_SYSTEM_NAME} STREQUAL "OpenBSD") | 93 if (NOT ${CMAKE_SYSTEM_NAME} STREQUAL "OpenBSD") |
93 link_libraries(rt) | 94 link_libraries(rt) |
94 endif() | 95 endif() |
95 | 96 |
113 # https://ohse.de/uwe/articles/lfs.html | 114 # https://ohse.de/uwe/articles/lfs.html |
114 add_definitions( | 115 add_definitions( |
115 -D_LARGEFILE64_SOURCE=1 | 116 -D_LARGEFILE64_SOURCE=1 |
116 -D_FILE_OFFSET_BITS=64 | 117 -D_FILE_OFFSET_BITS=64 |
117 ) | 118 ) |
118 endif() | |
119 | |
120 CHECK_INCLUDE_FILES(uuid/uuid.h HAVE_UUID_H) | |
121 if (NOT HAVE_UUID_H) | |
122 message(FATAL_ERROR "Please install the uuid-dev package (or e2fsprogs if OpenBSD)") | |
123 endif() | 119 endif() |
124 | 120 |
125 elseif(${CMAKE_SYSTEM_NAME} STREQUAL "Windows") | 121 elseif(${CMAKE_SYSTEM_NAME} STREQUAL "Windows") |
126 if (MSVC) | 122 if (MSVC) |
127 message("MSVC compiler version = " ${MSVC_VERSION} "\n") | 123 message("MSVC compiler version = " ${MSVC_VERSION} "\n") |
172 add_definitions( | 168 add_definitions( |
173 -D_XOPEN_SOURCE=1 | 169 -D_XOPEN_SOURCE=1 |
174 ) | 170 ) |
175 link_libraries(iconv) | 171 link_libraries(iconv) |
176 | 172 |
177 CHECK_INCLUDE_FILES(uuid/uuid.h HAVE_UUID_H) | |
178 if (NOT HAVE_UUID_H) | |
179 message(FATAL_ERROR "Please install the uuid-dev package") | |
180 endif() | |
181 | |
182 elseif (CMAKE_SYSTEM_NAME STREQUAL "Emscripten") | 173 elseif (CMAKE_SYSTEM_NAME STREQUAL "Emscripten") |
183 message("Building using Emscripten (for WebAssembly or asm.js targets)") | 174 message("Building using Emscripten (for WebAssembly or asm.js targets)") |
184 | 175 |
185 else() | 176 else() |
186 message(FATAL_ERROR "Support your platform here") | 177 message(FATAL_ERROR "Support your platform here") |
187 endif() | |
188 | |
189 | |
190 if ("${CMAKE_SYSTEM_VERSION}" STREQUAL "LinuxStandardBase") | |
191 SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} --lsb-target-version=${LSB_TARGET_VERSION} -I${LSB_PATH}/include") | |
192 SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --lsb-target-version=${LSB_TARGET_VERSION} -nostdinc++ -I${LSB_PATH}/include -I${LSB_PATH}/include/c++ -I${LSB_PATH}/include/c++/backward -fpermissive") | |
193 SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} --lsb-target-version=${LSB_TARGET_VERSION} -L${LSB_LIBPATH}") | |
194 endif() | 178 endif() |
195 | 179 |
196 | 180 |
197 if (DEFINED ENABLE_PROFILING AND ENABLE_PROFILING) | 181 if (DEFINED ENABLE_PROFILING AND ENABLE_PROFILING) |
198 if (NOT CMAKE_BUILD_TYPE STREQUAL "Debug") | 182 if (NOT CMAKE_BUILD_TYPE STREQUAL "Debug") |
209 message(FATAL_ERROR "Don't know how to enable profiling on your configuration") | 193 message(FATAL_ERROR "Don't know how to enable profiling on your configuration") |
210 endif() | 194 endif() |
211 endif() | 195 endif() |
212 | 196 |
213 | 197 |
198 if (CMAKE_COMPILER_IS_GNUCXX) | |
199 # "When creating a static library using binutils (ar) and there | |
200 # exist a duplicate object name (e.g. a/Foo.cpp.o, b/Foo.cpp.o), the | |
201 # resulting static library can end up having only one of the | |
202 # duplicate objects. [...] This bug only happens if there are many | |
203 # objects." https://cmake.org/Bug/view.php?id=14874 | |
204 set(CMAKE_CXX_ARCHIVE_APPEND "<CMAKE_AR> <LINK_FLAGS> q <TARGET> <OBJECTS>") | |
205 endif() | |
206 | |
207 | |
214 if (STATIC_BUILD) | 208 if (STATIC_BUILD) |
215 add_definitions(-DORTHANC_STATIC=1) | 209 add_definitions(-DORTHANC_STATIC=1) |
216 else() | 210 else() |
217 add_definitions(-DORTHANC_STATIC=0) | 211 add_definitions(-DORTHANC_STATIC=0) |
218 endif() | 212 endif() |