Mercurial > hg > orthanc
comparison Resources/CMake/Compiler.cmake @ 2364:ae50eccd41b7
compilation succeeds on OpenBSD
author | jodogne |
---|---|
date | Mon, 21 Aug 2017 16:28:53 +0200 |
parents | f47fd47b3c91 |
children | f0cfacd0c9b8 |
comparison
equal
deleted
inserted
replaced
2363:f8ef157f2d73 | 2364:ae50eccd41b7 |
---|---|
55 | 55 |
56 link_libraries(netapi32) | 56 link_libraries(netapi32) |
57 endif() | 57 endif() |
58 | 58 |
59 | 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 | |
60 if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux" OR | 70 if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux" OR |
61 ${CMAKE_SYSTEM_NAME} STREQUAL "kFreeBSD" OR | 71 ${CMAKE_SYSTEM_NAME} STREQUAL "kFreeBSD" OR |
62 ${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD") | 72 ${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD" OR |
63 set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -Wl,--no-undefined") | 73 ${CMAKE_SYSTEM_NAME} STREQUAL "OpenBSD") |
64 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() | |
65 | 81 |
66 if (NOT DEFINED ENABLE_PLUGINS_VERSION_SCRIPT OR | 82 if (NOT DEFINED ENABLE_PLUGINS_VERSION_SCRIPT OR |
67 ENABLE_PLUGINS_VERSION_SCRIPT) | 83 ENABLE_PLUGINS_VERSION_SCRIPT) |
68 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") |
69 endif() | 85 endif() |
70 | 86 |
71 # Remove the "-rdynamic" option | 87 # Remove the "-rdynamic" option |
72 # http://www.mail-archive.com/cmake@cmake.org/msg08837.html | 88 # http://www.mail-archive.com/cmake@cmake.org/msg08837.html |
73 set(CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS "") | 89 set(CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS "") |
74 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() | |
75 | 100 |
76 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 | |
77 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") |
78 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") |
79 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 | |
80 add_definitions( | 114 add_definitions( |
81 -D_LARGEFILE64_SOURCE=1 | 115 -D_LARGEFILE64_SOURCE=1 |
82 -D_FILE_OFFSET_BITS=64 | 116 -D_FILE_OFFSET_BITS=64 |
83 ) | 117 ) |
84 link_libraries(dl) | |
85 endif() | 118 endif() |
86 | 119 |
87 CHECK_INCLUDE_FILES(uuid/uuid.h HAVE_UUID_H) | 120 CHECK_INCLUDE_FILES(uuid/uuid.h HAVE_UUID_H) |
88 if (NOT HAVE_UUID_H) | 121 if (NOT HAVE_UUID_H) |
89 message(FATAL_ERROR "Please install the uuid-dev package") | 122 message(FATAL_ERROR "Please install the uuid-dev package (or e2fsprogs if OpenBSD)") |
90 endif() | 123 endif() |
91 | 124 |
92 elseif(${CMAKE_SYSTEM_NAME} STREQUAL "Windows") | 125 elseif(${CMAKE_SYSTEM_NAME} STREQUAL "Windows") |
93 if (MSVC) | 126 if (MSVC) |
94 message("MSVC compiler version = " ${MSVC_VERSION} "\n") | 127 message("MSVC compiler version = " ${MSVC_VERSION} "\n") |
144 CHECK_INCLUDE_FILES(uuid/uuid.h HAVE_UUID_H) | 177 CHECK_INCLUDE_FILES(uuid/uuid.h HAVE_UUID_H) |
145 if (NOT HAVE_UUID_H) | 178 if (NOT HAVE_UUID_H) |
146 message(FATAL_ERROR "Please install the uuid-dev package") | 179 message(FATAL_ERROR "Please install the uuid-dev package") |
147 endif() | 180 endif() |
148 | 181 |
182 else() | |
183 message(FATAL_ERROR "Support your platform here") | |
149 endif() | 184 endif() |
150 | 185 |
151 | 186 |
152 if ("${CMAKE_SYSTEM_VERSION}" STREQUAL "LinuxStandardBase") | 187 if ("${CMAKE_SYSTEM_VERSION}" STREQUAL "LinuxStandardBase") |
153 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") |
154 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") |
155 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}") |
156 endif() | |
157 | |
158 | |
159 if (${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD") | |
160 # In FreeBSD, the "/usr/local/" folder contains the ports and need to be imported | |
161 SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -I/usr/local/include") | |
162 SET(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} -I/usr/local/include") | |
163 SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -L/usr/local/lib") | |
164 SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -L/usr/local/lib") | |
165 endif() | 191 endif() |
166 | 192 |
167 | 193 |
168 if (DEFINED ENABLE_PROFILING AND ENABLE_PROFILING) | 194 if (DEFINED ENABLE_PROFILING AND ENABLE_PROFILING) |
169 if (NOT CMAKE_BUILD_TYPE STREQUAL "Debug") | 195 if (NOT CMAKE_BUILD_TYPE STREQUAL "Debug") |