annotate Resources/Orthanc/CMake/Compiler.cmake @ 33:44a0430d7899

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