comparison CMakeLists.txt @ 1:fd402e53d263

new files
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 01 Jun 2015 11:12:20 +0200
parents
children d5027f9f676a
comparison
equal deleted inserted replaced
0:ebc1e38ef615 1:fd402e53d263
1 # TODO !
2
3 cmake_minimum_required(VERSION 2.8)
4
5 project(OrthancClient)
6
7 OrthancCppClient/OrthancConnection.cpp
8 OrthancCppClient/Study.cpp
9 OrthancCppClient/Series.cpp
10 OrthancCppClient/Instance.cpp
11 OrthancCppClient/Patient.cpp
12
13
14
15
16 #####################################################################
17 ## Create the standalone DLL containing the Orthanc Client API
18 #####################################################################
19
20 include_directories(${ORTHANC_ROOT}/OrthancCppClient/SharedLibrary/Laaw)
21
22 if (${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
23 if (CMAKE_CROSSCOMPILING)
24 # Remove the default "lib" prefix from "libOrthancClient.dll" if cross-compiling
25 set(CMAKE_SHARED_LIBRARY_PREFIX "")
26
27 if (${CMAKE_SIZEOF_VOID_P} EQUAL 4)
28 set(ORTHANC_CPP_CLIENT_AUX ${ORTHANC_ROOT}/OrthancCppClient/SharedLibrary/AUTOGENERATED/Windows32.def)
29 elseif (${CMAKE_SIZEOF_VOID_P} EQUAL 8)
30 set(ORTHANC_CPP_CLIENT_AUX ${ORTHANC_ROOT}/OrthancCppClient/SharedLibrary/AUTOGENERATED/Windows64.def)
31 else()
32 message(FATAL_ERROR "Support your platform here")
33 endif()
34 else()
35 # Nothing to do if using Visual Studio
36 endif()
37
38 if (${CMAKE_SIZEOF_VOID_P} EQUAL 4)
39 set(CMAKE_SHARED_LIBRARY_SUFFIX "_Windows32.dll")
40 list(APPEND ORTHANC_CPP_CLIENT_AUX ${ORTHANC_ROOT}/OrthancCppClient/SharedLibrary/AUTOGENERATED/Windows32.rc)
41 elseif (${CMAKE_SIZEOF_VOID_P} EQUAL 8)
42 set(CMAKE_SHARED_LIBRARY_SUFFIX "_Windows64.dll")
43 list(APPEND ORTHANC_CPP_CLIENT_AUX ${ORTHANC_ROOT}/OrthancCppClient/SharedLibrary/AUTOGENERATED/Windows64.rc)
44 else()
45 message(FATAL_ERROR "Support your platform here")
46 endif()
47
48 else()
49 set(ORTHANC_CPP_CLIENT_AUX ${OPENSSL_SOURCES})
50 endif()
51
52 add_library(OrthancClient SHARED
53 ${ORTHANC_ROOT}/OrthancCppClient/OrthancCppClient.cpp
54 ${ORTHANC_ROOT}/OrthancCppClient/SharedLibrary/SharedLibrary.cpp
55 ${ORTHANC_ROOT}/Resources/ThirdParty/md5/md5.c
56 ${ORTHANC_ROOT}/Resources/ThirdParty/base64/base64.cpp
57 ${ORTHANC_CPP_CLIENT_AUX}
58 ${THIRD_PARTY_SOURCES}
59 ${CURL_SOURCES}
60 ${GOOGLE_LOG_SOURCES}
61 )
62
63 if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux" OR
64 ${CMAKE_SYSTEM_NAME} STREQUAL "kFreeBSD" OR
65 ${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD")
66 set_target_properties(OrthancClient
67 PROPERTIES LINK_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--no-undefined -Wl,--as-needed -Wl,--version-script=${ORTHANC_ROOT}/OrthancCppClient/SharedLibrary/Laaw/VersionScript.map"
68 )
69 target_link_libraries(OrthancClient pthread)
70
71 elseif (${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
72 target_link_libraries(OrthancClient OpenSSL ws2_32)
73
74 if (CMAKE_CROSSCOMPILING)
75 set_target_properties(OrthancClient
76 PROPERTIES LINK_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--allow-multiple-definition -static-libgcc -static-libstdc++"
77 )
78 endif()
79
80 elseif (${CMAKE_SYSTEM_NAME} STREQUAL "Darwin")
81 # TODO
82 target_link_libraries(OrthancClient pthread)
83
84 else()
85 message(FATAL_ERROR "Support your platform here")
86 endif()
87
88
89 # Set the version of the "Orthanc Client" shared library
90 file(STRINGS
91 ${CMAKE_SOURCE_DIR}/OrthancCppClient/SharedLibrary/Product.json
92 ORTHANC_CLIENT_VERSION_TMP
93 REGEX "^[ \t]*\"Version\"[ \t]*")
94
95 string(REGEX REPLACE "^.*\"([0-9]+)\\.([0-9]+)\\.([0-9]+)\"" "\\1.\\2"
96 ORTHANC_CLIENT_VERSION ${ORTHANC_CLIENT_VERSION_TMP})
97
98 message("Setting the version of the library to ${ORTHANC_CLIENT_VERSION}")
99
100 set_target_properties(OrthancClient PROPERTIES
101 VERSION ${ORTHANC_CLIENT_VERSION}
102 SOVERSION ${ORTHANC_CLIENT_VERSION})
103
104
105 install(
106 TARGETS OrthancClient
107 RUNTIME DESTINATION lib # Destination for Windows
108 LIBRARY DESTINATION lib # Destination for Linux
109 )
110
111 install(
112 FILES
113 ${ORTHANC_ROOT}/OrthancCppClient/SharedLibrary/AUTOGENERATED/OrthancCppClient.h
114 ${ORTHANC_ROOT}/Plugins/Include/OrthancCPlugin.h
115 ${ORTHANC_ROOT}/Plugins/Include/OrthancCDatabasePlugin.h
116 ${ORTHANC_ROOT}/Plugins/Include/OrthancCppDatabasePlugin.h
117 DESTINATION include/orthanc
118 )
119
120
121
122
123 #####################################################################
124 ## Generate the documentation if Doxygen is present
125 #####################################################################
126
127 find_package(Doxygen)
128 if (DOXYGEN_FOUND)
129 configure_file(
130 ${CMAKE_SOURCE_DIR}/Resources/OrthancClient.doxygen
131 ${CMAKE_CURRENT_BINARY_DIR}/OrthancClient.doxygen
132 @ONLY)
133
134 add_custom_command(TARGET OrthancClient
135 POST_BUILD
136 COMMAND ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/OrthancClient.doxygen
137 WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
138 COMMENT "Generating client documentation with Doxygen" VERBATIM
139 )
140
141 install(
142 DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/OrthancClientDocumentation/doc/
143 DESTINATION share/doc/orthanc/OrthancClient
144 )
145
146 else()
147 message("Doxygen not found. The documentation will not be built.")
148 endif()
149
150
151 #####################################################################
152 ## Prepare the "uninstall" target
153 ## http://www.cmake.org/Wiki/CMake_FAQ#Can_I_do_.22make_uninstall.22_with_CMake.3F
154 #####################################################################
155
156 configure_file(
157 "${CMAKE_CURRENT_SOURCE_DIR}/Resources/CMake/Uninstall.cmake.in"
158 "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
159 IMMEDIATE @ONLY)
160
161 add_custom_target(uninstall
162 COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake)