Mercurial > hg > orthanc-stone
annotate OrthancStone/Resources/Orthanc/CMake/Compiler.cmake @ 2177:4d21befb1501 default tip
clarify DICOMweb version check
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 23 Oct 2024 19:27:56 +0200 |
parents | ff1aefb43763 |
children |
rev | line source |
---|---|
1514 | 1 # Orthanc - A Lightweight, RESTful DICOM Store |
2 # Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics | |
3 # Department, University Hospital of Liege, Belgium | |
2133 | 4 # Copyright (C) 2017-2023 Osimis S.A., Belgium |
5 # Copyright (C) 2024-2024 Orthanc Team SRL, Belgium | |
2114
c23eef785569
update year to 2024
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2077
diff
changeset
|
6 # Copyright (C) 2021-2024 Sebastien Jodogne, ICTEAM UCLouvain, Belgium |
1514 | 7 # |
8 # This program is free software: you can redistribute it and/or | |
9 # modify it under the terms of the GNU Lesser General Public License | |
10 # as published by the Free Software Foundation, either version 3 of | |
11 # the License, or (at your option) any later version. | |
12 # | |
13 # This program is distributed in the hope that it will be useful, but | |
14 # WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
16 # Lesser General Public License for more details. | |
17 # | |
18 # You should have received a copy of the GNU Lesser General Public | |
19 # License along with this program. If not, see | |
20 # <http://www.gnu.org/licenses/>. | |
21 | |
22 | |
1508
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
23 # This file sets all the compiler-related flags |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
24 |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
25 |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
26 # Save the current compiler flags to the cache every time cmake configures the project |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
27 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}" CACHE STRING "compiler flags" FORCE) |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
28 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}" CACHE STRING "compiler flags" FORCE) |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
29 |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
30 |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
31 include(CheckLibraryExists) |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
32 |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
33 if ((CMAKE_CROSSCOMPILING AND NOT |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
34 "${CMAKE_SYSTEM_VERSION}" STREQUAL "CrossToolNg") OR |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
35 "${CMAKE_SYSTEM_VERSION}" STREQUAL "LinuxStandardBase") |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
36 # Cross-compilation necessarily implies standalone and static build |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
37 SET(STATIC_BUILD ON) |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
38 SET(STANDALONE_BUILD ON) |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
39 endif() |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
40 |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
41 |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
42 if ("${CMAKE_SYSTEM_VERSION}" STREQUAL "LinuxStandardBase") |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
43 # Cache the environment variables "LSB_CC" and "LSB_CXX" for further |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
44 # use by "ExternalProject" in CMake |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
45 SET(CMAKE_LSB_CC $ENV{LSB_CC} CACHE STRING "") |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
46 SET(CMAKE_LSB_CXX $ENV{LSB_CXX} CACHE STRING "") |
2114
c23eef785569
update year to 2024
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2077
diff
changeset
|
47 |
c23eef785569
update year to 2024
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2077
diff
changeset
|
48 # This is necessary to build "Orthanc mainline - Framework LSB |
c23eef785569
update year to 2024
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2077
diff
changeset
|
49 # Release" on "buildbot-worker-debian11" |
c23eef785569
update year to 2024
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2077
diff
changeset
|
50 set(LSB_PTHREAD_NONSHARED "${LSB_PATH}/lib64-${LSB_TARGET_VERSION}/libpthread_nonshared.a") |
c23eef785569
update year to 2024
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2077
diff
changeset
|
51 if (EXISTS ${LSB_PTHREAD_NONSHARED}) |
c23eef785569
update year to 2024
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2077
diff
changeset
|
52 set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${LSB_PTHREAD_NONSHARED}") |
c23eef785569
update year to 2024
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2077
diff
changeset
|
53 endif() |
1508
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
54 endif() |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
55 |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
56 |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
57 if (CMAKE_COMPILER_IS_GNUCXX) |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
58 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wno-long-long") |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
59 |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
60 # --std=c99 makes libcurl not to compile |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
61 # -pedantic gives a lot of warnings on OpenSSL |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
62 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wno-long-long -Wno-variadic-macros") |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
63 |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
64 if (CMAKE_CROSSCOMPILING) |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
65 # http://stackoverflow.com/a/3543845/881731 |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
66 set(CMAKE_RC_COMPILE_OBJECT "<CMAKE_RC_COMPILER> -O coff -I<CMAKE_CURRENT_SOURCE_DIR> <SOURCE> <OBJECT>") |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
67 endif() |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
68 |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
69 elseif (MSVC) |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
70 # Use static runtime under Visual Studio |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
71 # http://www.cmake.org/Wiki/CMake_FAQ#Dynamic_Replace |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
72 # http://stackoverflow.com/a/6510446 |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
73 foreach(flag_var |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
74 CMAKE_C_FLAGS_DEBUG |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
75 CMAKE_CXX_FLAGS_DEBUG |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
76 CMAKE_C_FLAGS_RELEASE |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
77 CMAKE_CXX_FLAGS_RELEASE |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
78 CMAKE_C_FLAGS_MINSIZEREL |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
79 CMAKE_CXX_FLAGS_MINSIZEREL |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
80 CMAKE_C_FLAGS_RELWITHDEBINFO |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
81 CMAKE_CXX_FLAGS_RELWITHDEBINFO) |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
82 string(REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}") |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
83 string(REGEX REPLACE "/MDd" "/MTd" ${flag_var} "${${flag_var}}") |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
84 endforeach(flag_var) |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
85 |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
86 # Add /Zm256 compiler option to Visual Studio to fix PCH errors |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
87 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Zm256") |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
88 |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
89 # New in Orthanc 1.5.5 |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
90 if (MSVC_MULTIPLE_PROCESSES) |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
91 # "If you omit the processMax argument in the /MP option, the |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
92 # compiler obtains the number of effective processors from the |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
93 # operating system, and then creates one process per effective |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
94 # processor" |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
95 # https://blog.kitware.com/cmake-building-with-all-your-cores/ |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
96 # https://docs.microsoft.com/en-us/cpp/build/reference/mp-build-with-multiple-processes |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
97 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /MP") |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
98 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP") |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
99 endif() |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
100 |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
101 add_definitions( |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
102 -D_CRT_SECURE_NO_WARNINGS=1 |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
103 -D_CRT_SECURE_NO_DEPRECATE=1 |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
104 ) |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
105 |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
106 if (MSVC_VERSION LESS 1600) |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
107 # Starting with Visual Studio >= 2010 (i.e. macro _MSC_VER >= |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
108 # 1600), Microsoft ships a standard-compliant <stdint.h> |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
109 # header. For earlier versions of Visual Studio, give access to a |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
110 # compatibility header. |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
111 # http://stackoverflow.com/a/70630/881731 |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
112 # https://en.wikibooks.org/wiki/C_Programming/C_Reference/stdint.h#External_links |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
113 include_directories(${CMAKE_CURRENT_LIST_DIR}/../../Resources/ThirdParty/VisualStudio) |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
114 endif() |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
115 |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
116 link_libraries(netapi32) |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
117 endif() |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
118 |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
119 |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
120 if (${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD" OR |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
121 ${CMAKE_SYSTEM_NAME} STREQUAL "OpenBSD") |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
122 # In FreeBSD/OpenBSD, the "/usr/local/" folder contains the ports and need to be imported |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
123 SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -I/usr/local/include") |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
124 SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -I/usr/local/include") |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
125 SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -L/usr/local/lib") |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
126 SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -L/usr/local/lib") |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
127 endif() |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
128 |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
129 |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
130 if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux" OR |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
131 ${CMAKE_SYSTEM_NAME} STREQUAL "kFreeBSD" OR |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
132 ${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD" OR |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
133 ${CMAKE_SYSTEM_NAME} STREQUAL "OpenBSD") |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
134 |
2114
c23eef785569
update year to 2024
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2077
diff
changeset
|
135 if (# NOT ${CMAKE_SYSTEM_VERSION} STREQUAL "LinuxStandardBase" AND |
c23eef785569
update year to 2024
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2077
diff
changeset
|
136 NOT ${CMAKE_SYSTEM_NAME} STREQUAL "OpenBSD" AND |
1508
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
137 NOT ${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD") |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
138 # The "--no-undefined" linker flag makes the shared libraries |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
139 # (plugins ModalityWorklists and ServeFolders) fail to compile on |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
140 # OpenBSD, and make the PostgreSQL plugin complain about missing |
2114
c23eef785569
update year to 2024
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2077
diff
changeset
|
141 # "environ" global variable in FreeBSD. |
c23eef785569
update year to 2024
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2077
diff
changeset
|
142 # |
c23eef785569
update year to 2024
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2077
diff
changeset
|
143 # TODO - Furthermore, on Linux Standard Base running on Debian 12, |
c23eef785569
update year to 2024
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2077
diff
changeset
|
144 # the "-Wl,--no-undefined" seems to break the compilation (added |
c23eef785569
update year to 2024
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2077
diff
changeset
|
145 # after Orthanc 1.12.2). This is disabled for now. |
1508
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
146 set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -Wl,--no-undefined") |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
147 set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--no-undefined") |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
148 endif() |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
149 |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
150 # Remove the "-rdynamic" option |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
151 # http://www.mail-archive.com/cmake@cmake.org/msg08837.html |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
152 set(CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS "") |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
153 link_libraries(pthread) |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
154 |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
155 if (NOT ${CMAKE_SYSTEM_NAME} STREQUAL "OpenBSD") |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
156 link_libraries(rt) |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
157 endif() |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
158 |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
159 if (NOT ${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD" AND |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
160 NOT ${CMAKE_SYSTEM_NAME} STREQUAL "OpenBSD") |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
161 link_libraries(dl) |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
162 endif() |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
163 |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
164 if (NOT ${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD" AND |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
165 NOT ${CMAKE_SYSTEM_NAME} STREQUAL "OpenBSD") |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
166 # The "--as-needed" linker flag is not available on FreeBSD and OpenBSD |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
167 set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--as-needed") |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
168 set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -Wl,--as-needed") |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
169 set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--as-needed") |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
170 endif() |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
171 |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
172 if (NOT ${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD" AND |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
173 NOT ${CMAKE_SYSTEM_NAME} STREQUAL "OpenBSD") |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
174 # FreeBSD/OpenBSD have just one single interface for file |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
175 # handling, which is 64bit clean, so there is no need to define macro |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
176 # for LFS (Large File Support). |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
177 # https://ohse.de/uwe/articles/lfs.html |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
178 add_definitions( |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
179 -D_LARGEFILE64_SOURCE=1 |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
180 -D_FILE_OFFSET_BITS=64 |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
181 ) |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
182 endif() |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
183 |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
184 elseif(${CMAKE_SYSTEM_NAME} STREQUAL "Windows") |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
185 if (MSVC) |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
186 message("MSVC compiler version = " ${MSVC_VERSION} "\n") |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
187 # Starting Visual Studio 2013 (version 1800), it is not possible |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
188 # to target Windows XP anymore |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
189 if (MSVC_VERSION LESS 1800) |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
190 add_definitions( |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
191 -DWINVER=0x0501 |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
192 -D_WIN32_WINNT=0x0501 |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
193 ) |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
194 endif() |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
195 else() |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
196 add_definitions( |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
197 -DWINVER=0x0501 |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
198 -D_WIN32_WINNT=0x0501 |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
199 ) |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
200 endif() |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
201 |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
202 add_definitions( |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
203 -D_CRT_SECURE_NO_WARNINGS=1 |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
204 ) |
1810 | 205 link_libraries(rpcrt4 ws2_32 iphlpapi) # "iphlpapi" is for "SystemToolbox::GetMacAddresses()" |
1508
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
206 |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
207 if (CMAKE_COMPILER_IS_GNUCXX) |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
208 # Some additional C/C++ compiler flags for MinGW |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
209 SET(MINGW_NO_WARNINGS "-Wno-unused-function -Wno-unused-variable") |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
210 SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${MINGW_NO_WARNINGS} -Wno-pointer-to-int-cast -Wno-int-to-pointer-cast") |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
211 SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${MINGW_NO_WARNINGS}") |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
212 |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
213 if (DYNAMIC_MINGW_STDLIB) |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
214 else() |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
215 # This is a patch for MinGW64 |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
216 SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--allow-multiple-definition -static-libgcc -static-libstdc++") |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
217 SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--allow-multiple-definition -static-libgcc -static-libstdc++") |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
218 endif() |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
219 |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
220 CHECK_LIBRARY_EXISTS(winpthread pthread_create "" HAVE_WIN_PTHREAD) |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
221 if (HAVE_WIN_PTHREAD) |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
222 if (DYNAMIC_MINGW_STDLIB) |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
223 else() |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
224 # This line is necessary to compile with recent versions of MinGW, |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
225 # otherwise "libwinpthread-1.dll" is not statically linked. |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
226 SET(CMAKE_CXX_STANDARD_LIBRARIES "${CMAKE_CXX_STANDARD_LIBRARIES} -Wl,-Bstatic -lstdc++ -lpthread -Wl,-Bdynamic") |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
227 endif() |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
228 add_definitions(-DHAVE_WIN_PTHREAD=1) |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
229 else() |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
230 add_definitions(-DHAVE_WIN_PTHREAD=0) |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
231 endif() |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
232 endif() |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
233 |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
234 elseif (${CMAKE_SYSTEM_NAME} STREQUAL "Darwin") |
2142 | 235 |
236 # fix this error that appears with recent compilers on MacOS: boost/mpl/aux_/integral_wrapper.hpp:73:31: error: integer value -1 is outside the valid range of values [0, 3] for this enumeration type [-Wenum-constexpr-conversion] | |
237 SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-enum-constexpr-conversion") | |
238 | |
1508
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
239 add_definitions( |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
240 -D_XOPEN_SOURCE=1 |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
241 ) |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
242 link_libraries(iconv) |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
243 |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
244 elseif (CMAKE_SYSTEM_NAME STREQUAL "Emscripten") |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
245 message("Building using Emscripten (for WebAssembly or asm.js targets)") |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
246 include(${CMAKE_CURRENT_LIST_DIR}/EmscriptenParameters.cmake) |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
247 |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
248 elseif (CMAKE_SYSTEM_NAME STREQUAL "Android") |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
249 |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
250 else() |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
251 message("Unknown target platform: ${CMAKE_SYSTEM_NAME}") |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
252 message(FATAL_ERROR "Support your platform here") |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
253 endif() |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
254 |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
255 |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
256 if (DEFINED ENABLE_PROFILING AND ENABLE_PROFILING) |
2077
07964689cb0b
upgrade to year 2023
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1871
diff
changeset
|
257 if (CMAKE_COMPILER_IS_GNUCXX OR |
07964689cb0b
upgrade to year 2023
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1871
diff
changeset
|
258 CMAKE_CXX_COMPILER_ID STREQUAL "Clang") |
1508
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
259 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pg") |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
260 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pg") |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
261 set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pg") |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
262 set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -pg") |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
263 set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -pg") |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
264 else() |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
265 message(FATAL_ERROR "Don't know how to enable profiling on your configuration") |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
266 endif() |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
267 endif() |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
268 |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
269 |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
270 if (CMAKE_COMPILER_IS_GNUCXX) |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
271 # "When creating a static library using binutils (ar) and there |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
272 # exist a duplicate object name (e.g. a/Foo.cpp.o, b/Foo.cpp.o), the |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
273 # resulting static library can end up having only one of the |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
274 # duplicate objects. [...] This bug only happens if there are many |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
275 # objects." The trick consists in replacing the "r" argument |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
276 # ("replace") provided to "ar" (as used in CMake < 3.1) by the "q" |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
277 # argument ("quick append"). This is because of the fact that CMake |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
278 # will invoke "ar" several times with several batches of ".o" |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
279 # objects, and using "r" would overwrite symbols defined in |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
280 # preceding batches. https://cmake.org/Bug/view.php?id=14874 |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
281 set(CMAKE_CXX_ARCHIVE_APPEND "<CMAKE_AR> <LINK_FLAGS> q <TARGET> <OBJECTS>") |
dd1d1cc0575d
use of OrthancPluginsExports.cmake, link against system-wide orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
282 endif() |
2077
07964689cb0b
upgrade to year 2023
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1871
diff
changeset
|
283 |
07964689cb0b
upgrade to year 2023
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1871
diff
changeset
|
284 |
07964689cb0b
upgrade to year 2023
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1871
diff
changeset
|
285 # This function defines macro "__ORTHANC_FILE__" as a replacement to |
07964689cb0b
upgrade to year 2023
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1871
diff
changeset
|
286 # macro "__FILE__", as the latter leaks the full path of the source |
07964689cb0b
upgrade to year 2023
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1871
diff
changeset
|
287 # files in the binaries |
07964689cb0b
upgrade to year 2023
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1871
diff
changeset
|
288 # https://stackoverflow.com/questions/8487986/file-macro-shows-full-path |
07964689cb0b
upgrade to year 2023
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1871
diff
changeset
|
289 # https://twitter.com/wget42/status/1676877802375634944?s=20 |
07964689cb0b
upgrade to year 2023
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1871
diff
changeset
|
290 function(DefineSourceBasenameForTarget targetname) |
07964689cb0b
upgrade to year 2023
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1871
diff
changeset
|
291 # Microsoft Visual Studio is extremely slow if using |
07964689cb0b
upgrade to year 2023
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1871
diff
changeset
|
292 # "set_property()", we only enable this feature for gcc and clang |
07964689cb0b
upgrade to year 2023
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1871
diff
changeset
|
293 if (CMAKE_COMPILER_IS_GNUCXX OR |
07964689cb0b
upgrade to year 2023
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1871
diff
changeset
|
294 CMAKE_CXX_COMPILER_ID STREQUAL "Clang") |
07964689cb0b
upgrade to year 2023
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1871
diff
changeset
|
295 get_target_property(source_files "${targetname}" SOURCES) |
07964689cb0b
upgrade to year 2023
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1871
diff
changeset
|
296 foreach(sourcefile ${source_files}) |
07964689cb0b
upgrade to year 2023
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1871
diff
changeset
|
297 get_filename_component(basename "${sourcefile}" NAME) |
07964689cb0b
upgrade to year 2023
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1871
diff
changeset
|
298 set_property( |
07964689cb0b
upgrade to year 2023
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1871
diff
changeset
|
299 SOURCE "${sourcefile}" APPEND |
07964689cb0b
upgrade to year 2023
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1871
diff
changeset
|
300 PROPERTY COMPILE_DEFINITIONS "__ORTHANC_FILE__=\"${basename}\"") |
07964689cb0b
upgrade to year 2023
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1871
diff
changeset
|
301 endforeach() |
07964689cb0b
upgrade to year 2023
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1871
diff
changeset
|
302 endif() |
07964689cb0b
upgrade to year 2023
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1871
diff
changeset
|
303 endfunction() |