@@ -1,53 +1,57 | |||
|
1 | 1 | # |
|
2 | 2 | # Sciqlop_modules.cmake |
|
3 | 3 | # |
|
4 | 4 | # Set ouptut directories |
|
5 | 5 | # |
|
6 | 6 | SET (EXECUTABLE_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR}/dist/${CMAKE_BUILD_TYPE}) |
|
7 | 7 | SET (LIBRARY_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR}/dist/${CMAKE_BUILD_TYPE}) |
|
8 | 8 | IF (UNIX) |
|
9 | 9 | SET (CONFIG_OUTPUT_PATH $ENV{HOME}/.config/QtProject) |
|
10 | 10 | ELSEIF(WIN32) |
|
11 | 11 | SET (CONFIG_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR}/dist/${CMAKE_BUILD_TYPE}/app/QtProject) |
|
12 | 12 | ELSE() |
|
13 | 13 | SET (CONFIG_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR}/dist/${CMAKE_BUILD_TYPE}) |
|
14 | 14 | ENDIF() |
|
15 | 15 | |
|
16 | 16 | INCLUDE ("cmake/sciqlop_code_coverage.cmake") |
|
17 | 17 | |
|
18 | if(BUILD_TESTS) | |
|
19 | APPEND_COVERAGE_COMPILER_FLAGS() | |
|
20 | endif(BUILD_TESTS) | |
|
21 | ||
|
18 | 22 | # |
|
19 | 23 | # Compile the diffents modules |
|
20 | 24 | # |
|
21 | 25 | set(sciqlop-core_DIR "${CMAKE_SOURCE_DIR}/core/cmake") |
|
22 | 26 | set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${sciqlop-core_DIR}") |
|
23 | 27 | ADD_SUBDIRECTORY("${CMAKE_SOURCE_DIR}/core") |
|
24 | 28 | |
|
25 | 29 | set(sciqlop-gui_DIR "${CMAKE_SOURCE_DIR}/gui/cmake") |
|
26 | 30 | set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${sciqlop-gui_DIR}") |
|
27 | 31 | ADD_SUBDIRECTORY("${CMAKE_SOURCE_DIR}/gui") |
|
28 | 32 | |
|
29 | 33 | ADD_SUBDIRECTORY("${CMAKE_SOURCE_DIR}/app") |
|
30 | 34 | |
|
31 | 35 | # LOGGER |
|
32 | 36 | set(QTLOGGING_INI_FILE "${CMAKE_SOURCE_DIR}/config/QtProject/qtlogging.ini") |
|
33 | 37 | FILE(COPY ${QTLOGGING_INI_FILE} DESTINATION ${CONFIG_OUTPUT_PATH}) |
|
34 | 38 | |
|
35 | 39 | |
|
36 | 40 | # |
|
37 | 41 | # Code formatting |
|
38 | 42 | # |
|
39 | 43 | # Vera++ exclusion files |
|
40 | 44 | LIST(APPEND CHECKSTYLE_EXCLUSION_FILES ${CMAKE_CURRENT_SOURCE_DIR}/formatting/vera-exclusions/exclusions.txt) |
|
41 | 45 | #SCIQLOP_SET_TO_PARENT_SCOPE(CHECKSTYLE_EXCLUSION_FILES) |
|
42 | 46 | INCLUDE ("cmake/sciqlop_formatting.cmake") |
|
43 | 47 | |
|
44 | 48 | # |
|
45 | 49 | # Documentation generation |
|
46 | 50 | # |
|
47 | 51 | INCLUDE ("cmake/sciqlop_doxygen.cmake") |
|
48 | 52 | |
|
49 | 53 | # |
|
50 | 54 | # Source code analysis |
|
51 | 55 | # |
|
52 | 56 | INCLUDE ("cmake/sciqlop_code_analysis.cmake") |
|
53 | 57 | INCLUDE ("cmake/sciqlop_code_cppcheck.cmake") |
@@ -1,249 +1,191 | |||
|
1 | 1 | # Copyright (c) 2012 - 2017, Lars Bilke |
|
2 | 2 | # All rights reserved. |
|
3 | 3 | # |
|
4 | 4 | # Redistribution and use in source and binary forms, with or without modification, |
|
5 | 5 | # are permitted provided that the following conditions are met: |
|
6 | 6 | # |
|
7 | 7 | # 1. Redistributions of source code must retain the above copyright notice, this |
|
8 | 8 | # list of conditions and the following disclaimer. |
|
9 | 9 | # |
|
10 | 10 | # 2. Redistributions in binary form must reproduce the above copyright notice, |
|
11 | 11 | # this list of conditions and the following disclaimer in the documentation |
|
12 | 12 | # and/or other materials provided with the distribution. |
|
13 | 13 | # |
|
14 | 14 | # 3. Neither the name of the copyright holder nor the names of its contributors |
|
15 | 15 | # may be used to endorse or promote products derived from this software without |
|
16 | 16 | # specific prior written permission. |
|
17 | 17 | # |
|
18 | 18 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND |
|
19 | 19 | # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
|
20 | 20 | # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
|
21 | 21 | # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR |
|
22 | 22 | # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
|
23 | 23 | # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
|
24 | 24 | # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON |
|
25 | 25 | # ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
|
26 | 26 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
|
27 | 27 | # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
|
28 | 28 | # |
|
29 | 29 | # CHANGES: |
|
30 | 30 | # |
|
31 | 31 | # 2012-01-31, Lars Bilke |
|
32 | 32 | # - Enable Code Coverage |
|
33 | 33 | # |
|
34 | 34 | # 2013-09-17, Joakim SΓΆderberg |
|
35 | 35 | # - Added support for Clang. |
|
36 | 36 | # - Some additional usage instructions. |
|
37 | 37 | # |
|
38 | 38 | # 2016-02-03, Lars Bilke |
|
39 | 39 | # - Refactored functions to use named parameters |
|
40 | 40 | # |
|
41 | 41 | # 2017-06-02, Lars Bilke |
|
42 | 42 | # - Merged with modified version from github.com/ufz/ogs |
|
43 | 43 | # |
|
44 | 44 | # |
|
45 | 45 | # USAGE: |
|
46 | 46 | # |
|
47 | 47 | # 1. Copy this file into your cmake modules path. |
|
48 | 48 | # |
|
49 | 49 | # 2. Add the following line to your CMakeLists.txt: |
|
50 | 50 | # include(CodeCoverage) |
|
51 | 51 | # |
|
52 | 52 | # 3. Append necessary compiler flags: |
|
53 | 53 | # APPEND_COVERAGE_COMPILER_FLAGS() |
|
54 | 54 | # |
|
55 | 55 | # 4. If you need to exclude additional directories from the report, specify them |
|
56 | 56 | # using the COVERAGE_EXCLUDES variable before calling SETUP_TARGET_FOR_COVERAGE. |
|
57 | 57 | # Example: |
|
58 | 58 | # set(COVERAGE_EXCLUDES 'dir1/*' 'dir2/*') |
|
59 | 59 | # |
|
60 | 60 | # 5. Use the function SETUP_TARGET_FOR_COVERAGE to create a custom make target |
|
61 | 61 | # which runs your test executable and produces a lcov code coverage report: |
|
62 | 62 | # Example: |
|
63 | 63 | # SETUP_TARGET_FOR_COVERAGE( |
|
64 | 64 | # my_coverage_target # Name for custom target. |
|
65 | 65 | # test_driver # Name of the test driver executable that runs the tests. |
|
66 | 66 | # # NOTE! This should always have a ZERO as exit code |
|
67 | 67 | # # otherwise the coverage generation will not complete. |
|
68 | 68 | # coverage # Name of output directory. |
|
69 | 69 | # ) |
|
70 | 70 | # |
|
71 | 71 | # 6. Build a Debug build: |
|
72 | 72 | # cmake -DCMAKE_BUILD_TYPE=Debug .. |
|
73 | 73 | # make |
|
74 | 74 | # make my_coverage_target |
|
75 | 75 | # |
|
76 | 76 | |
|
77 | 77 | include(CMakeParseArguments) |
|
78 | 78 | |
|
79 | 79 | # Check prereqs |
|
80 | 80 | find_program( GCOV_PATH gcov ) |
|
81 | 81 | find_program( LCOV_PATH lcov ) |
|
82 | 82 | find_program( GENHTML_PATH genhtml ) |
|
83 | 83 | find_program( GCOVR_PATH gcovr PATHS ${CMAKE_SOURCE_DIR}/scripts/test) |
|
84 | 84 | find_program( SIMPLE_PYTHON_EXECUTABLE python ) |
|
85 | 85 | |
|
86 | 86 | if(NOT GCOV_PATH) |
|
87 | 87 | message(FATAL_ERROR "gcov not found! Aborting...") |
|
88 | 88 | endif() # NOT GCOV_PATH |
|
89 | 89 | |
|
90 | 90 | if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(Apple)?[Cc]lang") |
|
91 | 91 | if("${CMAKE_CXX_COMPILER_VERSION}" VERSION_LESS 3) |
|
92 | 92 | message(FATAL_ERROR "Clang version must be 3.0.0 or greater! Aborting...") |
|
93 | 93 | endif() |
|
94 | 94 | elseif(NOT CMAKE_COMPILER_IS_GNUCXX) |
|
95 | 95 | message(FATAL_ERROR "Compiler is not GNU gcc! Aborting...") |
|
96 | 96 | endif() |
|
97 | 97 | |
|
98 | 98 | set(COVERAGE_COMPILER_FLAGS "-g -O0 --coverage -fprofile-arcs -ftest-coverage" |
|
99 | 99 | CACHE INTERNAL "") |
|
100 | 100 | |
|
101 | 101 | set(CMAKE_CXX_FLAGS_COVERAGE |
|
102 | 102 | ${COVERAGE_COMPILER_FLAGS} |
|
103 | 103 | CACHE STRING "Flags used by the C++ compiler during coverage builds." |
|
104 | 104 | FORCE ) |
|
105 | 105 | set(CMAKE_C_FLAGS_COVERAGE |
|
106 | 106 | ${COVERAGE_COMPILER_FLAGS} |
|
107 | 107 | CACHE STRING "Flags used by the C compiler during coverage builds." |
|
108 | 108 | FORCE ) |
|
109 | 109 | set(CMAKE_EXE_LINKER_FLAGS_COVERAGE |
|
110 | 110 | "" |
|
111 | 111 | CACHE STRING "Flags used for linking binaries during coverage builds." |
|
112 | 112 | FORCE ) |
|
113 | 113 | set(CMAKE_SHARED_LINKER_FLAGS_COVERAGE |
|
114 | 114 | "" |
|
115 | 115 | CACHE STRING "Flags used by the shared libraries linker during coverage builds." |
|
116 | 116 | FORCE ) |
|
117 | 117 | mark_as_advanced( |
|
118 | 118 | CMAKE_CXX_FLAGS_COVERAGE |
|
119 | 119 | CMAKE_C_FLAGS_COVERAGE |
|
120 | 120 | CMAKE_EXE_LINKER_FLAGS_COVERAGE |
|
121 | 121 | CMAKE_SHARED_LINKER_FLAGS_COVERAGE ) |
|
122 | 122 | |
|
123 | 123 | if(NOT CMAKE_BUILD_TYPE STREQUAL "Debug") |
|
124 | 124 | message(WARNING "Code coverage results with an optimised (non-Debug) build may be misleading") |
|
125 | 125 | endif() # NOT CMAKE_BUILD_TYPE STREQUAL "Debug" |
|
126 | 126 | |
|
127 | message( CMAKE_BUILD_TYPE : ${CMAKE_BUILD_TYPE}) | |
|
128 | 127 | if(CMAKE_COMPILER_IS_GNUCXX) |
|
129 | 128 | link_libraries(gcov) |
|
130 | 129 | else() |
|
131 | 130 | set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} --coverage") |
|
132 | 131 | endif() |
|
133 | 132 | |
|
134 | 133 | # Defines a target for running and collection code coverage information |
|
135 | 134 | # Builds dependencies, runs the given executable and outputs reports. |
|
136 | 135 | # NOTE! The executable should always have a ZERO as exit code otherwise |
|
137 | 136 | # the coverage generation will not complete. |
|
138 | 137 | # |
|
139 | 138 | # SETUP_TARGET_FOR_COVERAGE( |
|
140 | 139 | # NAME testrunner_coverage # New target name |
|
141 | 140 | # EXECUTABLE testrunner -j ${PROCESSOR_COUNT} # Executable in PROJECT_BINARY_DIR |
|
142 | 141 | # DEPENDENCIES testrunner # Dependencies to build first |
|
143 | 142 | # ) |
|
144 | 143 | function(SETUP_TARGET_FOR_COVERAGE) |
|
145 | 144 | |
|
146 | 145 | set(options NONE) |
|
147 |
set(oneValueArgs NAME TARGET |
|
|
146 | set(oneValueArgs NAME TARGET OUTPUT) | |
|
148 | 147 | set(multiValueArgs EXECUTABLE EXECUTABLE_ARGS DEPENDENCIES) |
|
149 | 148 | cmake_parse_arguments(Coverage "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) |
|
150 | 149 | |
|
151 | 150 | if(NOT LCOV_PATH) |
|
152 |
|
|
|
151 | message(FATAL_ERROR "lcov not found! Aborting...") | |
|
153 | 152 | endif() # NOT LCOV_PATH |
|
154 | 153 | |
|
155 | 154 | if(NOT GENHTML_PATH) |
|
156 |
|
|
|
155 | message(FATAL_ERROR "genhtml not found! Aborting...") | |
|
157 | 156 | endif() # NOT GENHTML_PATH |
|
158 | message("Coverage target: " ${Coverage_TARGET}) | |
|
159 | message("Coverage name: " ${Coverage_NAME}) | |
|
160 | message("Coverage exe: " ${Coverage_EXECUTABLE}) | |
|
161 | message("Coverage gcno: " ${Coverage_GCNO}) | |
|
162 | 157 | |
|
163 | 158 | # Setup target |
|
164 | 159 | add_custom_target(${Coverage_TARGET} |
|
165 | 160 | |
|
166 | 161 | # Cleanup lcov |
|
167 |
|
|
|
162 | COMMAND ${LCOV_PATH} --directory . --zerocounters | |
|
168 | 163 | |
|
169 | 164 | # Run tests |
|
170 | 165 | COMMAND ${Coverage_EXECUTABLE} |
|
171 | # Capturing lcov counters and generating report | |
|
172 | COMMAND gcov ${Coverage_NAME} --object-file ${Coverage_GCNO} | |
|
173 | 166 | |
|
174 | # COMMAND ${LCOV_PATH} --directory . --capture --output-file ${Coverage_NAME}.info | |
|
175 |
|
|
|
176 |
|
|
|
177 |
|
|
|
167 | # Capturing lcov counters and generating report | |
|
168 | COMMAND ${LCOV_PATH} --directory . --capture --output-file ${Coverage_NAME}.info | |
|
169 | COMMAND ${LCOV_PATH} --remove ${Coverage_NAME}.info ${COVERAGE_EXCLUDES} --output-file ${Coverage_NAME}.info.cleaned | |
|
170 | COMMAND ${GENHTML_PATH} -o ${Coverage_OUTPUT} ${Coverage_NAME}.info.cleaned | |
|
171 | COMMAND ${CMAKE_COMMAND} -E remove ${Coverage_NAME}.info ${Coverage_NAME}.info.cleaned | |
|
178 | 172 | |
|
179 | 173 | WORKING_DIRECTORY ${PROJECT_BINARY_DIR} |
|
180 | 174 | DEPENDS ${Coverage_DEPENDENCIES} |
|
181 | 175 | COMMENT "Resetting code coverage counters to zero.\nProcessing code coverage counters and generating report." |
|
182 | 176 | ) |
|
183 | 177 | |
|
184 | 178 | # Show info where to find the report |
|
185 | 179 | # message("Nome de la target ${Coverage_TARGET}") |
|
186 | 180 | # add_custom_command(TARGET ${Coverage_TARGET} POST_BUILD |
|
187 | 181 | # COMMAND ; |
|
188 | 182 | # COMMENT "Open ./${Coverage_NAME}/index.html in your browser to view the coverage report." |
|
189 | 183 | # ) |
|
190 | 184 | |
|
191 | endfunction() # SETUP_TARGET_FOR_COVERAGE | |
|
192 | ||
|
193 | # Defines a target for running and collection code coverage information | |
|
194 | # Builds dependencies, runs the given executable and outputs reports. | |
|
195 | # NOTE! The executable should always have a ZERO as exit code otherwise | |
|
196 | # the coverage generation will not complete. | |
|
197 | # | |
|
198 | # SETUP_TARGET_FOR_COVERAGE_COBERTURA( | |
|
199 | # NAME ctest_coverage # New target name | |
|
200 | # EXECUTABLE ctest -j ${PROCESSOR_COUNT} # Executable in PROJECT_BINARY_DIR | |
|
201 | # DEPENDENCIES executable_target # Dependencies to build first | |
|
202 | # ) | |
|
203 | function(SETUP_TARGET_FOR_COVERAGE_COBERTURA) | |
|
204 | ||
|
205 | set(options NONE) | |
|
206 | set(oneValueArgs NAME) | |
|
207 | set(multiValueArgs EXECUTABLE EXECUTABLE_ARGS DEPENDENCIES) | |
|
208 | cmake_parse_arguments(Coverage "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) | |
|
209 | ||
|
210 | if(NOT SIMPLE_PYTHON_EXECUTABLE) | |
|
211 | message(FATAL_ERROR "python not found! Aborting...") | |
|
212 | endif() # NOT SIMPLE_PYTHON_EXECUTABLE | |
|
213 | ||
|
214 | if(NOT GCOVR_PATH) | |
|
215 | message(FATAL_ERROR "gcovr not found! Aborting...") | |
|
216 | endif() # NOT GCOVR_PATH | |
|
217 | ||
|
218 | # Combine excludes to several -e arguments | |
|
219 | set(COBERTURA_EXCLUDES "") | |
|
220 | foreach(EXCLUDE ${COVERAGE_EXCLUDES}) | |
|
221 | set(COBERTURA_EXCLUDES "-e ${EXCLUDE} ${COBERTURA_EXCLUDES}") | |
|
222 | endforeach() | |
|
223 | ||
|
224 | add_custom_target(${Coverage_NAME} | |
|
225 | ||
|
226 | # Run tests | |
|
227 | ${Coverage_EXECUTABLE} | |
|
228 | ||
|
229 | # Running gcovr | |
|
230 | COMMAND ${GCOVR_PATH} -x -r ${CMAKE_SOURCE_DIR} ${COBERTURA_EXCLUDES} | |
|
231 | -o ${Coverage_NAME}.xml | |
|
232 | WORKING_DIRECTORY ${PROJECT_BINARY_DIR} | |
|
233 | DEPENDS ${Coverage_DEPENDENCIES} | |
|
234 | COMMENT "Running gcovr to produce Cobertura code coverage report." | |
|
235 | ) | |
|
236 | ||
|
237 | # Show info where to find the report | |
|
238 | add_custom_command(TARGET ${Coverage_NAME} POST_BUILD | |
|
239 | COMMAND ; | |
|
240 | COMMENT "Cobertura code coverage report saved in ${Coverage_NAME}.xml." | |
|
241 | ) | |
|
242 | ||
|
243 | endfunction() # SETUP_TARGET_FOR_COVERAGE_COBERTURA | |
|
185 | endfunction() | |
|
244 | 186 | |
|
245 | 187 | function(APPEND_COVERAGE_COMPILER_FLAGS) |
|
246 | 188 | set(CMAKE_C_FLAGS "${CMAKE_CXX_FLAGS} ${COVERAGE_COMPILER_FLAGS}" PARENT_SCOPE) |
|
247 | 189 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${COVERAGE_COMPILER_FLAGS}" PARENT_SCOPE) |
|
248 | 190 | message(STATUS "Appending code coverage compiler flags: ${COVERAGE_COMPILER_FLAGS}") |
|
249 | 191 | endfunction() # APPEND_COVERAGE_COMPILER_FLAGS |
@@ -1,137 +1,132 | |||
|
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 | |
|
8 | 8 | # Include core directory |
|
9 | 9 | include_directories("${INCLUDES_DIR}") |
|
10 | 10 | |
|
11 | 11 | # Set a variable to display a warning in the version files. |
|
12 | 12 | SET(SCIQLOP_CMAKE_GENERATION_WARNING "DON'T CHANGE THIS FILE. AUTOGENERATED BY CMAKE.") |
|
13 | 13 | # Generate the version file from the cmake version variables. The version |
|
14 | 14 | # variables are defined in the cmake/sciqlop_version.cmake file. |
|
15 | 15 | CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/resources/Version.h.in" |
|
16 | 16 | "${INCLUDES_DIR}/Version.h") |
|
17 | 17 | CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/resources/Version.cpp.in" |
|
18 | 18 | "${SOURCES_DIR}/Version.cpp") |
|
19 | 19 | |
|
20 | 20 | # |
|
21 | 21 | # Find Qt modules |
|
22 | 22 | # |
|
23 | 23 | SCIQLOP_FIND_QT(Core) |
|
24 | 24 | |
|
25 | 25 | # |
|
26 | 26 | # Compile the library library |
|
27 | 27 | # |
|
28 | 28 | FILE (GLOB_RECURSE MODULE_SOURCES |
|
29 | 29 | ${INCLUDES_DIR}/*.h |
|
30 | 30 | ${SOURCES_DIR}/*.c |
|
31 | 31 | ${SOURCES_DIR}/*.cpp |
|
32 | 32 | ${SOURCES_DIR}/*.h) |
|
33 | 33 | |
|
34 | 34 | ADD_LIBRARY(${SQPCORE_LIBRARY_NAME} ${MODULE_SOURCES}) |
|
35 | 35 | set_property(TARGET ${SQPCORE_LIBRARY_NAME} PROPERTY CXX_STANDARD 14) |
|
36 | 36 | set_property(TARGET ${SQPCORE_LIBRARY_NAME} PROPERTY CXX_STANDARD_REQUIRED ON) |
|
37 | 37 | TARGET_LINK_LIBRARIES(${SQPCORE_LIBRARY_NAME}) |
|
38 | 38 | qt5_use_modules(${SQPCORE_LIBRARY_NAME} Core) |
|
39 | 39 | |
|
40 | 40 | # From cmake documentation: http://www.cmake.org/cmake/help/v3.0/manual/cmake-buildsystem.7.html |
|
41 | 41 | # Entries in the COMPILE_DEFINITIONS are prefixed with -D or /D and added to the compile line in an unspecified order. |
|
42 | 42 | # The DEFINE_SYMBOL target property is also added as a compile definition as a special convenience case for SHARED and MODULE library targets |
|
43 | 43 | IF(BUILD_SHARED_LIBS) |
|
44 | 44 | SET_TARGET_PROPERTIES(${SQPCORE_LIBRARY_NAME} PROPERTIES COMPILE_DEFINITIONS "SCIQLOP_EXPORT") |
|
45 | 45 | ELSE() |
|
46 | 46 | TARGET_COMPILE_DEFINITIONS(${SQPCORE_LIBRARY_NAME} PUBLIC "SCIQLOP_STATIC_LIBRARIES") |
|
47 | 47 | ENDIF() |
|
48 | 48 | |
|
49 | 49 | # Set the variable to parent scope so that the other projects can copy the |
|
50 | 50 | # dependent shared libraries |
|
51 | 51 | SCIQLOP_SET_TO_PARENT_SCOPE(SQPCORE_LIBRARY_NAME) |
|
52 | 52 | |
|
53 | 53 | # Copy extern shared libraries to the lib folder |
|
54 | 54 | SCIQLOP_COPY_TO_TARGET(LIBRARY ${SQPCORE_LIBRARY_NAME} ${EXTERN_SHARED_LIBRARIES}) |
|
55 | 55 | |
|
56 | 56 | # Add the files to the list of files to be analyzed |
|
57 | 57 | LIST(APPEND CHECKSTYLE_INPUT_FILES ${MODULE_SOURCES}) |
|
58 | 58 | SCIQLOP_SET_TO_PARENT_SCOPE(CHECKSTYLE_INPUT_FILES) |
|
59 | 59 | # Vera++ exclusion files |
|
60 | 60 | LIST(APPEND CHECKSTYLE_EXCLUSION_FILES ${CMAKE_CURRENT_SOURCE_DIR}/vera-exclusions/exclusions.txt) |
|
61 | 61 | SCIQLOP_SET_TO_PARENT_SCOPE(CHECKSTYLE_EXCLUSION_FILES) |
|
62 | 62 | |
|
63 | 63 | # |
|
64 | 64 | # Compile the tests |
|
65 | 65 | # |
|
66 | 66 | IF(BUILD_TESTS) |
|
67 | 67 | INCLUDE_DIRECTORIES(${SOURCES_DIR}) |
|
68 | 68 | FILE (GLOB_RECURSE TESTS_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/Test*.cpp) |
|
69 | 69 | FILE (GLOB_RECURSE TESTS_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/Test*.h) |
|
70 | 70 | SET( TEST_LIBRARIES ${SQPCORE_LIBRARY_NAME}) |
|
71 | 71 | |
|
72 | 72 | FOREACH( testFile ${TESTS_SOURCES} ) |
|
73 | 73 | GET_FILENAME_COMPONENT( testDirectory ${testFile} DIRECTORY ) |
|
74 | 74 | GET_FILENAME_COMPONENT( testName ${testFile} NAME_WE ) |
|
75 | 75 | |
|
76 | 76 | # Add to the list of sources files all the sources in the same |
|
77 | 77 | # directory that aren't another test |
|
78 | 78 | FILE (GLOB currentTestSources |
|
79 | 79 | ${testDirectory}/*.c |
|
80 | 80 | ${testDirectory}/*.cpp |
|
81 | 81 | ${testDirectory}/*.h) |
|
82 | 82 | LIST (REMOVE_ITEM currentTestSources ${TESTS_SOURCES}) |
|
83 | 83 | # LIST (REMOVE_ITEM currentTestSources ${TESTS_HEADERS}) |
|
84 | 84 | |
|
85 | 85 | ADD_EXECUTABLE(${testName} ${testFile} ${currentTestSources}) |
|
86 | 86 | set_property(TARGET ${testName} PROPERTY CXX_STANDARD 14) |
|
87 | 87 | set_property(TARGET ${testName} PROPERTY CXX_STANDARD_REQUIRED ON) |
|
88 | 88 | TARGET_LINK_LIBRARIES( ${testName} ${TEST_LIBRARIES} ) |
|
89 | 89 | qt5_use_modules(${testName} Test) |
|
90 | 90 | |
|
91 | 91 | ADD_TEST( NAME ${testName} COMMAND ${testDirectory} ) |
|
92 | 92 | |
|
93 | set({testGCNO} ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${testName}.dir/tests/) | |
|
94 | ||
|
95 | # MESSAGE("Current build did :" ${testGCNO}) | |
|
96 | MESSAGE("Current build did :" ${CMAKE_FILES_DIRECTORY}) | |
|
97 | MESSAGE("Current build did :" ${currentTestSources}) | |
|
98 | 93 | SCIQLOP_COPY_TO_TARGET(RUNTIME ${testName} ${EXTERN_SHARED_LIBRARIES}) |
|
99 | 94 | set(Coverage_NAME ${testName}) |
|
100 | SETUP_TARGET_FOR_COVERAGE(TARGET ${testName}_coverage NAME ${testFile} EXECUTABLE ${testName}) | |
|
95 | SETUP_TARGET_FOR_COVERAGE(TARGET ${testName}_coverage OUTPUT ${testFile}-path NAME ${testFile} EXECUTABLE ${testName}) | |
|
101 | 96 | ENDFOREACH( testFile ) |
|
102 | 97 | |
|
103 | 98 | LIST(APPEND testFilesToFormat ${TESTS_SOURCES}) |
|
104 | 99 | LIST(APPEND testFilesToFormat ${TESTS_HEADERS}) |
|
105 | 100 | LIST(APPEND FORMATTING_INPUT_FILES ${testFilesToFormat}) |
|
106 | 101 | SCIQLOP_SET_TO_PARENT_SCOPE(FORMATTING_INPUT_FILES) |
|
107 | 102 | ENDIF(BUILD_TESTS) |
|
108 | 103 | |
|
109 | 104 | # |
|
110 | 105 | # Set the files that must be formatted by clang-format. |
|
111 | 106 | # |
|
112 | 107 | LIST (APPEND FORMATTING_INPUT_FILES ${MODULE_SOURCES}) |
|
113 | 108 | SCIQLOP_SET_TO_PARENT_SCOPE(FORMATTING_INPUT_FILES) |
|
114 | 109 | |
|
115 | 110 | # |
|
116 | 111 | # Set the directories that doxygen must browse to generate the |
|
117 | 112 | # documentation. |
|
118 | 113 | # |
|
119 | 114 | # Source directories: |
|
120 | 115 | LIST (APPEND DOXYGEN_INPUT_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/docs") |
|
121 | 116 | LIST (APPEND DOXYGEN_INPUT_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/src") |
|
122 | 117 | SCIQLOP_SET_TO_PARENT_SCOPE(DOXYGEN_INPUT_DIRS) |
|
123 | 118 | # Source directories to exclude from the documentation generation |
|
124 | 119 | #LIST (APPEND DOXYGEN_EXCLUDE_PATTERNS "${CMAKE_CURRENT_SOURCE_DIR}/path/to/subdir/*") |
|
125 | 120 | SCIQLOP_SET_TO_PARENT_SCOPE(DOXYGEN_EXCLUDE_PATTERNS) |
|
126 | 121 | |
|
127 | 122 | # |
|
128 | 123 | # Set the directories with the sources to analyze and propagate the |
|
129 | 124 | # modification to the parent scope |
|
130 | 125 | # |
|
131 | 126 | # Source directories to analyze: |
|
132 | 127 | LIST (APPEND ANALYSIS_INPUT_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/src") |
|
133 | 128 | LIST (APPEND ANALYSIS_INPUT_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/tests") |
|
134 | 129 | SCIQLOP_SET_TO_PARENT_SCOPE(ANALYSIS_INPUT_DIRS) |
|
135 | 130 | # Source directories to exclude from the analysis |
|
136 | 131 | #LIST (APPEND ANALYSIS_EXCLUDE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/path/to/subdir") |
|
137 | 132 | SCIQLOP_SET_TO_PARENT_SCOPE(ANALYSIS_EXCLUDE_DIRS) |
General Comments 0
You need to be logged in to leave comments.
Login now