comparison OrthancStone/Resources/Orthanc/CMake/Compiler.cmake @ 2077:07964689cb0b

upgrade to year 2023
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 12 Jul 2023 21:20:22 +0200
parents 7053b8a0aaec
children c23eef785569
comparison
equal deleted inserted replaced
2076:990f396484b1 2077:07964689cb0b
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-2022 Osimis S.A., Belgium 4 # Copyright (C) 2017-2023 Osimis S.A., Belgium
5 # Copyright (C) 2021-2022 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()