##// END OF EJS Templates
Add Apple runtime config to find CatalogueAPI at runtime when building with cmake
Thibaud Rabillard -
r1061:124e87e46711
parent child
Show More
@@ -1,168 +1,171
1 1
2 2 ## core - CMakeLists.txt
3 3 STRING(TOLOWER ${CMAKE_PROJECT_NAME} LIBRARY_PREFFIX)
4 4 SET(SQPCORE_LIBRARY_NAME "${LIBRARY_PREFFIX}_core${DEBUG_SUFFIX}")
5 5 SET(SOURCES_DIR "${CMAKE_CURRENT_SOURCE_DIR}/src/")
6 6 SET(INCLUDES_DIR "${CMAKE_CURRENT_SOURCE_DIR}/include/")
7 7 SET(TESTS_RESOURCES_DIR "${CMAKE_CURRENT_SOURCE_DIR}/tests-resources")
8 8
9 9 # Include core directory
10 10 include_directories("${INCLUDES_DIR}")
11 11
12 12 # Set a variable to display a warning in the version files.
13 13 SET(SCIQLOP_CMAKE_GENERATION_WARNING "DON'T CHANGE THIS FILE. AUTOGENERATED BY CMAKE.")
14 14 # Generate the version file from the cmake version variables. The version
15 15 # variables are defined in the cmake/sciqlop_version.cmake file.
16 16 CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/resources/Version.h.in"
17 17 "${INCLUDES_DIR}/Version.h")
18 18 CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/resources/Version.cpp.in"
19 19 "${SOURCES_DIR}/Version.cpp")
20 20
21 21 # Find dependent modules
22 22 find_package(sciqlop-plugin)
23 23 INCLUDE_DIRECTORIES(${SCIQLOP-PLUGIN_INCLUDE_DIR})
24 24
25 25 #
26 26 # Find Qt modules
27 27 #
28 28 SCIQLOP_FIND_QT(Core Network)
29 29
30 30 #
31 31 # Compile the library library
32 32 #
33 33
34 34 ADD_DEFINITIONS(-DCORE_LIB)
35 35
36 36 FILE (GLOB_RECURSE MODULE_SOURCES
37 37 ${INCLUDES_DIR}/*.h
38 38 ${SOURCES_DIR}/*.c
39 39 ${SOURCES_DIR}/*.cpp
40 40 ${SOURCES_DIR}/*.h)
41 41
42 42 ADD_LIBRARY(${SQPCORE_LIBRARY_NAME} ${MODULE_SOURCES})
43 43 set_property(TARGET ${SQPCORE_LIBRARY_NAME} PROPERTY CXX_STANDARD 14)
44 44 set_property(TARGET ${SQPCORE_LIBRARY_NAME} PROPERTY CXX_STANDARD_REQUIRED ON)
45 45 TARGET_LINK_LIBRARIES(${SQPCORE_LIBRARY_NAME})
46 46 qt5_use_modules(${SQPCORE_LIBRARY_NAME} Core Network)
47 47
48 48 # Find CATALOGUE_API
49 49 if(CATALOGUEAPI_FOUND)
50 50 include_directories("${CATALOGUEAPI_INCLUDE_DIRS}")
51 51 TARGET_LINK_LIBRARIES(${SQPCORE_LIBRARY_NAME} ${CATALOGUEAPI_LIBRARIES})
52 52 endif()
53 53
54 54 INSTALL(TARGETS ${SQPCORE_LIBRARY_NAME}
55 55 RUNTIME DESTINATION ${INSTALL_BINARY_DIR}
56 56 LIBRARY DESTINATION ${INSTALL_LIBRARY_DIR}
57 57 ARCHIVE DESTINATION ${INSTALL_LIBRARY_DIR}
58 58 )
59 59
60 60 # From cmake documentation: http://www.cmake.org/cmake/help/v3.0/manual/cmake-buildsystem.7.html
61 61 # Entries in the COMPILE_DEFINITIONS are prefixed with -D or /D and added to the compile line in an unspecified order.
62 62 # The DEFINE_SYMBOL target property is also added as a compile definition as a special convenience case for SHARED and MODULE library targets
63 63 IF(BUILD_SHARED_LIBS)
64 64 SET_TARGET_PROPERTIES(${SQPCORE_LIBRARY_NAME} PROPERTIES COMPILE_DEFINITIONS "SCIQLOP_EXPORT")
65 65 ELSE()
66 66 TARGET_COMPILE_DEFINITIONS(${SQPCORE_LIBRARY_NAME} PUBLIC "SCIQLOP_STATIC_LIBRARIES")
67 67 ENDIF()
68 68
69 69 # Set the variable to parent scope so that the other projects can copy the
70 70 # dependent shared libraries
71 71 SCIQLOP_SET_TO_PARENT_SCOPE(SQPCORE_LIBRARY_NAME)
72 72
73 73 # Copy extern shared libraries to the lib folder
74 74 LIST (APPEND ${EXTERN_SHARED_LIBRARIES} ${CATALOGUEAPI_LIBRARIES})
75 75
76 76 SCIQLOP_COPY_TO_TARGET(LIBRARY ${SQPCORE_LIBRARY_NAME} ${CATALOGUEAPI_LIBRARIES})
77 if(APPLE)
78 SCIQLOP_COPY_TO_TARGET(RUNTIME ${SQPCORE_LIBRARY_NAME} ${CATALOGUEAPI_LIBRARIES})
79 endif()
77 80 SCIQLOP_COPY_TO_TARGET(LIBRARY ${SQPCORE_LIBRARY_NAME} ${EXTERN_SHARED_LIBRARIES})
78 81
79 82 # Add the files to the list of files to be analyzed
80 83 LIST(APPEND CHECKSTYLE_INPUT_FILES ${MODULE_SOURCES})
81 84 SCIQLOP_SET_TO_PARENT_SCOPE(CHECKSTYLE_INPUT_FILES)
82 85 # Vera++ exclusion files
83 86 LIST(APPEND CHECKSTYLE_EXCLUSION_FILES ${CMAKE_CURRENT_SOURCE_DIR}/vera-exclusions/exclusions.txt)
84 87 SCIQLOP_SET_TO_PARENT_SCOPE(CHECKSTYLE_EXCLUSION_FILES)
85 88
86 89 #
87 90 # Compile the tests
88 91 #
89 92 IF(BUILD_TESTS)
90 93 INCLUDE_DIRECTORIES(${SOURCES_DIR})
91 94 FILE (GLOB_RECURSE TESTS_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/Test*.cpp)
92 95 FILE (GLOB_RECURSE TESTS_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/Test*.h)
93 96 SET( TEST_LIBRARIES ${SQPCORE_LIBRARY_NAME})
94 97
95 98 SET(TARGETS_COV)
96 99 FOREACH( testFile ${TESTS_SOURCES} )
97 100 GET_FILENAME_COMPONENT( testDirectory ${testFile} DIRECTORY )
98 101 GET_FILENAME_COMPONENT( testName ${testFile} NAME_WE )
99 102
100 103 # Add to the list of sources files all the sources in the same
101 104 # directory that aren't another test
102 105 FILE (GLOB currentTestSources
103 106 ${testDirectory}/*.c
104 107 ${testDirectory}/*.cpp
105 108 ${testDirectory}/*.h)
106 109 LIST (REMOVE_ITEM currentTestSources ${TESTS_SOURCES})
107 110 # LIST (REMOVE_ITEM currentTestSources ${TESTS_HEADERS})
108 111
109 112 ADD_EXECUTABLE(${testName} ${testFile} ${currentTestSources})
110 113 set_property(TARGET ${testName} PROPERTY CXX_STANDARD 14)
111 114 set_property(TARGET ${testName} PROPERTY CXX_STANDARD_REQUIRED ON)
112 115 TARGET_LINK_LIBRARIES( ${testName} ${TEST_LIBRARIES} )
113 116 qt5_use_modules(${testName} Test)
114 117
115 118 ADD_TEST( NAME ${testName} COMMAND ${testName} )
116 119
117 120 SCIQLOP_COPY_TO_TARGET(RUNTIME ${testName} ${EXTERN_SHARED_LIBRARIES})
118 121 set(Coverage_NAME ${testName})
119 122 if(UNIX)
120 123 SETUP_TARGET_FOR_COVERAGE(TARGET ${testName}_coverage OUTPUT ${testFile}-path NAME ${testFile} EXECUTABLE ${testName})
121 124 LIST( APPEND TARGETS_COV ${testName}_coverage)
122 125 endif(UNIX)
123 126
124 127 ENDFOREACH( testFile )
125 128
126 129 add_custom_target(coverage)
127 130
128 131 FOREACH( target_cov ${TARGETS_COV} )
129 132 add_custom_command(TARGET coverage PRE_BUILD COMMAND make ${target_cov})
130 133 ENDFOREACH( target_cov )
131 134
132 135 LIST(APPEND testFilesToFormat ${TESTS_SOURCES})
133 136 LIST(APPEND testFilesToFormat ${TESTS_HEADERS})
134 137 LIST(APPEND FORMATTING_INPUT_FILES ${testFilesToFormat})
135 138 SCIQLOP_SET_TO_PARENT_SCOPE(FORMATTING_INPUT_FILES)
136 139
137 140 ADD_DEFINITIONS(-DCORE_TESTS_RESOURCES_DIR="${TESTS_RESOURCES_DIR}")
138 141 ENDIF(BUILD_TESTS)
139 142
140 143 #
141 144 # Set the files that must be formatted by clang-format.
142 145 #
143 146 LIST (APPEND FORMATTING_INPUT_FILES ${MODULE_SOURCES})
144 147 SCIQLOP_SET_TO_PARENT_SCOPE(FORMATTING_INPUT_FILES)
145 148
146 149 #
147 150 # Set the directories that doxygen must browse to generate the
148 151 # documentation.
149 152 #
150 153 # Source directories:
151 154 LIST (APPEND DOXYGEN_INPUT_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/docs")
152 155 LIST (APPEND DOXYGEN_INPUT_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/src")
153 156 SCIQLOP_SET_TO_PARENT_SCOPE(DOXYGEN_INPUT_DIRS)
154 157 # Source directories to exclude from the documentation generation
155 158 #LIST (APPEND DOXYGEN_EXCLUDE_PATTERNS "${CMAKE_CURRENT_SOURCE_DIR}/path/to/subdir/*")
156 159 SCIQLOP_SET_TO_PARENT_SCOPE(DOXYGEN_EXCLUDE_PATTERNS)
157 160
158 161 #
159 162 # Set the directories with the sources to analyze and propagate the
160 163 # modification to the parent scope
161 164 #
162 165 # Source directories to analyze:
163 166 LIST (APPEND ANALYSIS_INPUT_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/src")
164 167 LIST (APPEND ANALYSIS_INPUT_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/tests")
165 168 SCIQLOP_SET_TO_PARENT_SCOPE(ANALYSIS_INPUT_DIRS)
166 169 # Source directories to exclude from the analysis
167 170 #LIST (APPEND ANALYSIS_EXCLUDE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/path/to/subdir")
168 171 SCIQLOP_SET_TO_PARENT_SCOPE(ANALYSIS_EXCLUDE_DIRS)
General Comments 0
You need to be logged in to leave comments. Login now