Mercurial > hg > orthanc-wsi
comparison Resources/Orthanc/CMake/Compiler.cmake @ 254:20a730889ae2
upgrade to 2023
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 07 Jul 2023 17:38:07 +0200 |
parents | 5ed8d1cee52d |
children | 7020852a8fa9 |
comparison
equal
deleted
inserted
replaced
253:a40295af8771 | 254:20a730889ae2 |
---|---|
1 # Orthanc - A Lightweight, RESTful DICOM Store | 1 # Orthanc - A Lightweight, RESTful DICOM Store |
2 # Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics | 2 # Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics |
3 # Department, University Hospital of Liege, Belgium | 3 # Department, University Hospital of Liege, Belgium |
4 # Copyright (C) 2017-2021 Osimis S.A., Belgium | 4 # Copyright (C) 2017-2023 Osimis S.A., Belgium |
5 # Copyright (C) 2021-2021 Sebastien Jodogne, ICTEAM UCLouvain, Belgium | 5 # Copyright (C) 2021-2023 Sebastien Jodogne, ICTEAM UCLouvain, Belgium |
6 # | 6 # |
7 # This program is free software: you can redistribute it and/or | 7 # This program is free software: you can redistribute it and/or |
8 # modify it under the terms of the GNU Lesser General Public License | 8 # modify it under the terms of the GNU Lesser General Public License |
9 # as published by the Free Software Foundation, either version 3 of | 9 # as published by the Free Software Foundation, either version 3 of |
10 # the License, or (at your option) any later version. | 10 # the License, or (at your option) any later version. |
235 message(FATAL_ERROR "Support your platform here") | 235 message(FATAL_ERROR "Support your platform here") |
236 endif() | 236 endif() |
237 | 237 |
238 | 238 |
239 if (DEFINED ENABLE_PROFILING AND ENABLE_PROFILING) | 239 if (DEFINED ENABLE_PROFILING AND ENABLE_PROFILING) |
240 if (CMAKE_COMPILER_IS_GNUCXX) | 240 if (CMAKE_COMPILER_IS_GNUCXX OR |
241 CMAKE_CXX_COMPILER_ID STREQUAL "Clang") | |
241 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pg") | 242 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pg") |
242 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pg") | 243 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pg") |
243 set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pg") | 244 set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pg") |
244 set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -pg") | 245 set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -pg") |
245 set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -pg") | 246 set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -pg") |
260 # will invoke "ar" several times with several batches of ".o" | 261 # will invoke "ar" several times with several batches of ".o" |
261 # objects, and using "r" would overwrite symbols defined in | 262 # objects, and using "r" would overwrite symbols defined in |
262 # preceding batches. https://cmake.org/Bug/view.php?id=14874 | 263 # preceding batches. https://cmake.org/Bug/view.php?id=14874 |
263 set(CMAKE_CXX_ARCHIVE_APPEND "<CMAKE_AR> <LINK_FLAGS> q <TARGET> <OBJECTS>") | 264 set(CMAKE_CXX_ARCHIVE_APPEND "<CMAKE_AR> <LINK_FLAGS> q <TARGET> <OBJECTS>") |
264 endif() | 265 endif() |
266 | |
267 | |
268 # This function defines macro "__ORTHANC_FILE__" as a replacement to | |
269 # macro "__FILE__", as the latter leaks the full path of the source | |
270 # files in the binaries | |
271 # https://stackoverflow.com/questions/8487986/file-macro-shows-full-path | |
272 # https://twitter.com/wget42/status/1676877802375634944?s=20 | |
273 function(DefineSourceBasenameForTarget targetname) | |
274 # Microsoft Visual Studio is extremely slow if using | |
275 # "set_property()", we only enable this feature for gcc and clang | |
276 if (CMAKE_COMPILER_IS_GNUCXX OR | |
277 CMAKE_CXX_COMPILER_ID STREQUAL "Clang") | |
278 get_target_property(source_files "${targetname}" SOURCES) | |
279 foreach(sourcefile ${source_files}) | |
280 get_filename_component(basename "${sourcefile}" NAME) | |
281 set_property( | |
282 SOURCE "${sourcefile}" APPEND | |
283 PROPERTY COMPILE_DEFINITIONS "__ORTHANC_FILE__=\"${basename}\"") | |
284 endforeach() | |
285 endif() | |
286 endfunction() |