Mercurial > hg > orthanc-webviewer
comparison Orthanc/Resources/CMake/Compiler.cmake @ 167:bd5597966b3d
sync
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 22 Aug 2017 21:46:50 +0200 |
parents | 08f30c8962a7 |
children | 330ecfd96aec |
comparison
equal
deleted
inserted
replaced
166:e5ac1fd6cf7d | 167:bd5597966b3d |
---|---|
5 SET(STATIC_BUILD ON) | 5 SET(STATIC_BUILD ON) |
6 SET(STANDALONE_BUILD ON) | 6 SET(STANDALONE_BUILD ON) |
7 endif() | 7 endif() |
8 | 8 |
9 if (CMAKE_COMPILER_IS_GNUCXX) | 9 if (CMAKE_COMPILER_IS_GNUCXX) |
10 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wno-long-long -Wno-implicit-function-declaration") | 10 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wno-long-long") |
11 | |
11 # --std=c99 makes libcurl not to compile | 12 # --std=c99 makes libcurl not to compile |
12 # -pedantic gives a lot of warnings on OpenSSL | 13 # -pedantic gives a lot of warnings on OpenSSL |
13 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wno-long-long -Wno-variadic-macros") | 14 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wno-long-long -Wno-variadic-macros") |
14 | 15 |
15 if (CMAKE_CROSSCOMPILING) | 16 if (CMAKE_CROSSCOMPILING) |
54 | 55 |
55 link_libraries(netapi32) | 56 link_libraries(netapi32) |
56 endif() | 57 endif() |
57 | 58 |
58 | 59 |
60 if (${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD" OR | |
61 ${CMAKE_SYSTEM_NAME} STREQUAL "OpenBSD") | |
62 # In FreeBSD/OpenBSD, the "/usr/local/" folder contains the ports and need to be imported | |
63 SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -I/usr/local/include") | |
64 SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -I/usr/local/include") | |
65 SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -L/usr/local/lib") | |
66 SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -L/usr/local/lib") | |
67 endif() | |
68 | |
69 | |
59 if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux" OR | 70 if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux" OR |
60 ${CMAKE_SYSTEM_NAME} STREQUAL "kFreeBSD" OR | 71 ${CMAKE_SYSTEM_NAME} STREQUAL "kFreeBSD" OR |
61 ${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD") | 72 ${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD" OR |
62 set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -Wl,--no-undefined") | 73 ${CMAKE_SYSTEM_NAME} STREQUAL "OpenBSD") |
63 set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--no-undefined") | 74 |
75 if (NOT ${CMAKE_SYSTEM_NAME} STREQUAL "OpenBSD") | |
76 # The "--no-undefined" linker flag makes the shared libraries | |
77 # (plugins ModalityWorklists and ServeFolders) fail to compile on OpenBSD | |
78 set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -Wl,--no-undefined") | |
79 set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--no-undefined") | |
80 endif() | |
64 | 81 |
65 if (NOT DEFINED ENABLE_PLUGINS_VERSION_SCRIPT OR | 82 if (NOT DEFINED ENABLE_PLUGINS_VERSION_SCRIPT OR |
66 ENABLE_PLUGINS_VERSION_SCRIPT) | 83 ENABLE_PLUGINS_VERSION_SCRIPT) |
67 set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--version-script=${ORTHANC_ROOT}/Plugins/Samples/Common/VersionScript.map") | 84 set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--version-script=${ORTHANC_ROOT}/Plugins/Samples/Common/VersionScript.map") |
68 endif() | 85 endif() |
69 | 86 |
70 # Remove the "-rdynamic" option | 87 # Remove the "-rdynamic" option |
71 # http://www.mail-archive.com/cmake@cmake.org/msg08837.html | 88 # http://www.mail-archive.com/cmake@cmake.org/msg08837.html |
72 set(CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS "") | 89 set(CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS "") |
73 link_libraries(uuid pthread rt) | 90 link_libraries(uuid pthread) |
91 | |
92 if (NOT ${CMAKE_SYSTEM_NAME} STREQUAL "OpenBSD") | |
93 link_libraries(rt) | |
94 endif() | |
95 | |
96 if (NOT ${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD" AND | |
97 NOT ${CMAKE_SYSTEM_NAME} STREQUAL "OpenBSD") | |
98 link_libraries(dl) | |
99 endif() | |
74 | 100 |
75 if (NOT ${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD") | 101 if (NOT ${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD") |
102 # The "--as-needed" linker flag is not available on FreeBSD | |
76 set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--as-needed") | 103 set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--as-needed") |
77 set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -Wl,--as-needed") | 104 set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -Wl,--as-needed") |
78 set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--as-needed") | 105 set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--as-needed") |
106 endif() | |
107 | |
108 if (NOT ${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD" AND | |
109 NOT ${CMAKE_SYSTEM_NAME} STREQUAL "OpenBSD") | |
110 # FreeBSD/OpenBSD have just one single interface for file | |
111 # handling, which is 64bit clean, so there is no need to define macro | |
112 # for LFS (Large File Support). | |
113 # https://ohse.de/uwe/articles/lfs.html | |
79 add_definitions( | 114 add_definitions( |
80 -D_LARGEFILE64_SOURCE=1 | 115 -D_LARGEFILE64_SOURCE=1 |
81 -D_FILE_OFFSET_BITS=64 | 116 -D_FILE_OFFSET_BITS=64 |
82 ) | 117 ) |
83 link_libraries(dl) | |
84 endif() | 118 endif() |
85 | 119 |
86 CHECK_INCLUDE_FILES(uuid/uuid.h HAVE_UUID_H) | 120 CHECK_INCLUDE_FILES(uuid/uuid.h HAVE_UUID_H) |
87 if (NOT HAVE_UUID_H) | 121 if (NOT HAVE_UUID_H) |
88 message(FATAL_ERROR "Please install the uuid-dev package") | 122 message(FATAL_ERROR "Please install the uuid-dev package (or e2fsprogs if OpenBSD)") |
89 endif() | 123 endif() |
90 | 124 |
91 elseif(${CMAKE_SYSTEM_NAME} STREQUAL "Windows") | 125 elseif(${CMAKE_SYSTEM_NAME} STREQUAL "Windows") |
92 if (MSVC) | 126 if (MSVC) |
93 message("MSVC compiler version = " ${MSVC_VERSION} "\n") | 127 message("MSVC compiler version = " ${MSVC_VERSION} "\n") |
143 CHECK_INCLUDE_FILES(uuid/uuid.h HAVE_UUID_H) | 177 CHECK_INCLUDE_FILES(uuid/uuid.h HAVE_UUID_H) |
144 if (NOT HAVE_UUID_H) | 178 if (NOT HAVE_UUID_H) |
145 message(FATAL_ERROR "Please install the uuid-dev package") | 179 message(FATAL_ERROR "Please install the uuid-dev package") |
146 endif() | 180 endif() |
147 | 181 |
182 else() | |
183 message(FATAL_ERROR "Support your platform here") | |
148 endif() | 184 endif() |
149 | 185 |
150 | 186 |
151 if ("${CMAKE_SYSTEM_VERSION}" STREQUAL "LinuxStandardBase") | 187 if ("${CMAKE_SYSTEM_VERSION}" STREQUAL "LinuxStandardBase") |
152 SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} --lsb-target-version=${LSB_TARGET_VERSION} -I${LSB_PATH}/include") | 188 SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} --lsb-target-version=${LSB_TARGET_VERSION} -I${LSB_PATH}/include") |
153 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") | 189 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") |
154 SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} --lsb-target-version=${LSB_TARGET_VERSION} -L${LSB_LIBPATH}") | 190 SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} --lsb-target-version=${LSB_TARGET_VERSION} -L${LSB_LIBPATH}") |
155 endif() | |
156 | |
157 | |
158 if (${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD") | |
159 # In FreeBSD, the "/usr/local/" folder contains the ports and need to be imported | |
160 SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -I/usr/local/include") | |
161 SET(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} -I/usr/local/include") | |
162 SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -L/usr/local/lib") | |
163 SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -L/usr/local/lib") | |
164 endif() | 191 endif() |
165 | 192 |
166 | 193 |
167 if (DEFINED ENABLE_PROFILING AND ENABLE_PROFILING) | 194 if (DEFINED ENABLE_PROFILING AND ENABLE_PROFILING) |
168 if (NOT CMAKE_BUILD_TYPE STREQUAL "Debug") | 195 if (NOT CMAKE_BUILD_TYPE STREQUAL "Debug") |