annotate CMakeLists.txt @ 24:3bed39e4b85f

fix prefix and suffix for Windows Python libraries
author Benjamin Golinvaux <bgo@osimis.io>
date Fri, 03 Apr 2020 12:12:09 +0200
parents 874a3fef26ff
children 3b59f5dd7e72
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
7ed502b17b8f initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1 cmake_minimum_required(VERSION 2.8)
7ed502b17b8f initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2 project(OrthancPython)
7ed502b17b8f initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3
15
c4c3590e2024 back to mainline
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 14
diff changeset
4 set(PLUGIN_VERSION "mainline")
0
7ed502b17b8f initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
5
7ed502b17b8f initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
6
7ed502b17b8f initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7 set(PYTHON_VERSION "3.6" CACHE STRING "Version of Python to be used")
7ed502b17b8f initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
8 set(PYTHON_WINDOWS_ROOT "" CACHE STRING "")
7ed502b17b8f initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
9 set(USE_SYSTEM_BOOST ON CACHE BOOL "Use the system version of Boost")
7ed502b17b8f initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
10 set(USE_SYSTEM_JSONCPP ON CACHE BOOL "Use the system version of JsonCpp")
7ed502b17b8f initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
11 set(USE_LEGACY_JSONCPP OFF CACHE BOOL "Use the old branch 0.x.y of JsonCpp, that does not require a C++11 compiler (for LSB and old versions of Visual Studio)")
7ed502b17b8f initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12
7ed502b17b8f initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13 include(CheckIncludeFile)
7ed502b17b8f initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
14 include(CheckIncludeFileCXX)
7ed502b17b8f initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
15 include(CheckIncludeFiles)
7ed502b17b8f initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
16 include(CheckLibraryExists)
16
777b677cc9fc generation of windows resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 14
diff changeset
17 include(FindPythonInterp)
0
7ed502b17b8f initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
18
21
67f48fc2fd69 fix linking with Python on Windows
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 17
diff changeset
19 string(REGEX REPLACE "^([0-9]*)\\.([0-9]*)$" "\\1" PYTHON_VERSION_MAJOR ${PYTHON_VERSION})
67f48fc2fd69 fix linking with Python on Windows
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 17
diff changeset
20 string(REGEX REPLACE "^([0-9]*)\\.([0-9]*)$" "\\2" PYTHON_VERSION_MINOR ${PYTHON_VERSION})
67f48fc2fd69 fix linking with Python on Windows
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 17
diff changeset
21
67f48fc2fd69 fix linking with Python on Windows
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 17
diff changeset
22 if (NOT PYTHON_VERSION STREQUAL
67f48fc2fd69 fix linking with Python on Windows
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 17
diff changeset
23 "${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}")
67f48fc2fd69 fix linking with Python on Windows
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 17
diff changeset
24 message(FATAL_ERROR "Error in the (x.y) format of the Python version: ${PYTHON_VERSION}")
67f48fc2fd69 fix linking with Python on Windows
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 17
diff changeset
25 endif()
67f48fc2fd69 fix linking with Python on Windows
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 17
diff changeset
26
0
7ed502b17b8f initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
27 if (${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
23
874a3fef26ff fix suffix of Windows library
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 21
diff changeset
28 if (MSVC)
24
3bed39e4b85f fix prefix and suffix for Windows Python libraries
Benjamin Golinvaux <bgo@osimis.io>
parents: 23
diff changeset
29 set(Prefix "")
23
874a3fef26ff fix suffix of Windows library
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 21
diff changeset
30 set(Suffix ".lib")
874a3fef26ff fix suffix of Windows library
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 21
diff changeset
31 else()
24
3bed39e4b85f fix prefix and suffix for Windows Python libraries
Benjamin Golinvaux <bgo@osimis.io>
parents: 23
diff changeset
32 set(Prefix "lib")
23
874a3fef26ff fix suffix of Windows library
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 21
diff changeset
33 set(Suffix ".a")
874a3fef26ff fix suffix of Windows library
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 21
diff changeset
34 endif()
874a3fef26ff fix suffix of Windows library
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 21
diff changeset
35
24
3bed39e4b85f fix prefix and suffix for Windows Python libraries
Benjamin Golinvaux <bgo@osimis.io>
parents: 23
diff changeset
36 set(PYTHON_LIBRARY_NAME ${Prefix}python${PYTHON_VERSION_MAJOR}${PYTHON_VERSION_MINOR}${Suffix})
0
7ed502b17b8f initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
37 set(PYTHON_INCLUDE_DIRS ${PYTHON_WINDOWS_ROOT}/include)
21
67f48fc2fd69 fix linking with Python on Windows
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 17
diff changeset
38 set(PYTHON_LIBRARIES ${PYTHON_WINDOWS_ROOT}/libs/${PYTHON_LIBRARY_NAME})
0
7ed502b17b8f initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
39
7ed502b17b8f initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
40 else()
7ed502b17b8f initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
41 find_package(PkgConfig REQUIRED)
7ed502b17b8f initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
42 pkg_check_modules(PYTHON_1 python-${PYTHON_VERSION}-embed)
7ed502b17b8f initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
43
7ed502b17b8f initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
44 if (PYTHON_1_FOUND)
7ed502b17b8f initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
45 set(PYTHON_INCLUDE_DIRS ${PYTHON_1_INCLUDE_DIRS})
7ed502b17b8f initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
46 set(PYTHON_LIBRARIES ${PYTHON_1_LIBRARIES})
7ed502b17b8f initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
47 else()
7ed502b17b8f initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
48 pkg_check_modules(PYTHON_2 REQUIRED python-${PYTHON_VERSION})
7ed502b17b8f initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
49 set(PYTHON_INCLUDE_DIRS ${PYTHON_2_INCLUDE_DIRS})
7ed502b17b8f initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
50 set(PYTHON_LIBRARIES ${PYTHON_2_LIBRARIES})
7ed502b17b8f initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
51 endif()
7ed502b17b8f initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
52 endif()
7ed502b17b8f initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
53
7ed502b17b8f initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
54 set(ORTHANC_ROOT ${CMAKE_SOURCE_DIR}/Resources/Orthanc)
7ed502b17b8f initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
55 include(${ORTHANC_ROOT}/Resources/CMake/Compiler.cmake)
7ed502b17b8f initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
56 include(${ORTHANC_ROOT}/Resources/CMake/DownloadPackage.cmake)
7ed502b17b8f initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
57 include(${ORTHANC_ROOT}/Resources/CMake/BoostConfiguration.cmake)
7ed502b17b8f initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
58 include(${ORTHANC_ROOT}/Resources/CMake/JsonCppConfiguration.cmake)
7ed502b17b8f initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
59
16
777b677cc9fc generation of windows resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 14
diff changeset
60
777b677cc9fc generation of windows resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 14
diff changeset
61 if (${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
777b677cc9fc generation of windows resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 14
diff changeset
62 execute_process(
777b677cc9fc generation of windows resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 14
diff changeset
63 COMMAND
777b677cc9fc generation of windows resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 14
diff changeset
64 ${PYTHON_EXECUTABLE} ${ORTHANC_ROOT}/Resources/WindowsResources.py
777b677cc9fc generation of windows resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 14
diff changeset
65 ${PLUGIN_VERSION} "Python plugin" OrthancPython.dll
777b677cc9fc generation of windows resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 14
diff changeset
66 "Plugin to create Orthanc plugins using Python"
777b677cc9fc generation of windows resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 14
diff changeset
67 ERROR_VARIABLE Failure
777b677cc9fc generation of windows resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 14
diff changeset
68 OUTPUT_FILE ${CMAKE_CURRENT_BINARY_DIR}/Version.rc
777b677cc9fc generation of windows resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 14
diff changeset
69 )
777b677cc9fc generation of windows resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 14
diff changeset
70
777b677cc9fc generation of windows resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 14
diff changeset
71 if (Failure)
777b677cc9fc generation of windows resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 14
diff changeset
72 message(FATAL_ERROR "Error while computing the version information: ${Failure}")
777b677cc9fc generation of windows resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 14
diff changeset
73 endif()
777b677cc9fc generation of windows resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 14
diff changeset
74
777b677cc9fc generation of windows resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 14
diff changeset
75 set(WINDOWS_RESOURCES ${CMAKE_CURRENT_BINARY_DIR}/Version.rc)
777b677cc9fc generation of windows resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 14
diff changeset
76 endif()
777b677cc9fc generation of windows resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 14
diff changeset
77
777b677cc9fc generation of windows resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 14
diff changeset
78
4
e3128420249d fixing the SDK version
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 0
diff changeset
79 include_directories(
e3128420249d fixing the SDK version
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 0
diff changeset
80 ${ORTHANC_ROOT}/Sdk-1.5.7
e3128420249d fixing the SDK version
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 0
diff changeset
81 )
0
7ed502b17b8f initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
82
7ed502b17b8f initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
83 add_definitions(
7ed502b17b8f initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
84 -DHAS_ORTHANC_EXCEPTION=0
7ed502b17b8f initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
85 )
7ed502b17b8f initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
86
7ed502b17b8f initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
87 include_directories(
7ed502b17b8f initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
88 ${ORTHANC_ROOT}/Plugins/Samples/Common
7ed502b17b8f initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
89 ${PYTHON_INCLUDE_DIRS}
7ed502b17b8f initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
90 )
7ed502b17b8f initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
91
7ed502b17b8f initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
92 add_library(OrthancPython SHARED
7ed502b17b8f initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
93 ${BOOST_SOURCES}
7ed502b17b8f initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
94 ${JSONCPP_SOURCES}
7ed502b17b8f initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
95 ${ORTHANC_ROOT}/Plugins/Samples/Common/OrthancPluginCppWrapper.cpp
16
777b677cc9fc generation of windows resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 14
diff changeset
96 ${WINDOWS_RESOURCES}
0
7ed502b17b8f initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
97 Sources/Autogenerated/sdk.cpp
7ed502b17b8f initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
98 Sources/OnChangeCallback.cpp
7ed502b17b8f initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
99 Sources/OnStoredInstanceCallback.cpp
7ed502b17b8f initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
100 Sources/Plugin.cpp
7ed502b17b8f initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
101 Sources/PythonFunction.cpp
7ed502b17b8f initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
102 Sources/PythonLock.cpp
7ed502b17b8f initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
103 Sources/PythonModule.cpp
7ed502b17b8f initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
104 Sources/PythonObject.cpp
7ed502b17b8f initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
105 Sources/PythonString.cpp
7ed502b17b8f initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
106 Sources/RestCallbacks.cpp
7ed502b17b8f initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
107 )
7ed502b17b8f initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
108
7ed502b17b8f initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
109 target_link_libraries(OrthancPython ${PYTHON_LIBRARIES})
7ed502b17b8f initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
110
7ed502b17b8f initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
111 add_definitions(-DPLUGIN_VERSION="${PLUGIN_VERSION}")
7ed502b17b8f initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
112
7ed502b17b8f initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
113 set_target_properties(OrthancPython PROPERTIES
7ed502b17b8f initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
114 VERSION ${PLUGIN_VERSION}
7ed502b17b8f initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
115 SOVERSION ${PLUGIN_VERSION}
7ed502b17b8f initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
116 )
7ed502b17b8f initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
117
7ed502b17b8f initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
118 install(
7ed502b17b8f initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
119 TARGETS OrthancPython
7ed502b17b8f initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
120 RUNTIME DESTINATION lib # Destination for Windows
7ed502b17b8f initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
121 LIBRARY DESTINATION share/orthanc/plugins # Destination for Linux
7ed502b17b8f initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
122 )