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