##// END OF EJS Templates
Add target to copy MockPlugin library in "plugins" directory after compilation
Alexandre Leroux -
r103:6ac01596a3cb
parent child
Show More
@@ -1,147 +1,153
1 1 ## mockplugin - CMakeLists.txt
2 2 STRING(TOLOWER ${CMAKE_PROJECT_NAME} LIBRARY_PREFFIX)
3 3 SET(SQPMOCKPLUGIN_LIBRARY_NAME "${LIBRARY_PREFFIX}_mockplugin${DEBUG_SUFFIX}")
4 4 SET(SOURCES_DIR "${CMAKE_CURRENT_SOURCE_DIR}/src")
5 5 SET(INCLUDES_DIR "${CMAKE_CURRENT_SOURCE_DIR}/include")
6 6 SET(RESOURCES_DIR "${CMAKE_CURRENT_SOURCE_DIR}/resources")
7 7
8 8 # Include mockplugin directory
9 9 INCLUDE_DIRECTORIES(${INCLUDES_DIR})
10 10 INCLUDE_DIRECTORIES(${RESOURCES_DIR})
11 11
12 12 #
13 13 # Find Qt modules
14 14 #
15 15 SCIQLOP_FIND_QT(Core Widgets)
16 16
17 17 #
18 18 # Find dependent libraries
19 19 # ========================
20 20
21 21 # sciqlop plugin
22 22 find_package(sciqlop-plugin)
23 23 INCLUDE_DIRECTORIES(${SCIQLOP-PLUGIN_INCLUDE_DIR})
24 24
25 25 # sciqlop core
26 26 find_package(sciqlop-core)
27 27 INCLUDE_DIRECTORIES(${SCIQLOP-CORE_INCLUDE_DIR})
28 28 list(APPEND LIBRARIES ${SCIQLOP-CORE_LIBRARIES})
29 29
30 30 # sciqlop gui
31 31 find_package(sciqlop-gui)
32 32 INCLUDE_DIRECTORIES(${SCIQLOP-GUI_INCLUDE_DIR})
33 33 list(APPEND LIBRARIES ${SCIQLOP-GUI_LIBRARIES})
34 34
35 35 # Resources files
36 36 FILE (GLOB_RECURSE PROJECT_RESOURCES ${RESOURCES_DIR}/*.json)
37 37
38 38 #
39 39 # Compile the library
40 40 #
41 41 FILE (GLOB_RECURSE MODULE_SOURCES
42 42 ${INCLUDES_DIR}/*.h
43 43 ${SOURCES_DIR}/*.c
44 44 ${SOURCES_DIR}/*.cpp
45 45 ${SOURCES_DIR}/*.h
46 46 ${PROJECT_RESOURCES})
47 47
48 48 ADD_LIBRARY(${SQPMOCKPLUGIN_LIBRARY_NAME} ${MODULE_SOURCES})
49 49 set_property(TARGET ${SQPMOCKPLUGIN_LIBRARY_NAME} PROPERTY CXX_STANDARD 14)
50 50 set_property(TARGET ${SQPMOCKPLUGIN_LIBRARY_NAME} PROPERTY CXX_STANDARD_REQUIRED ON)
51 51
52 52 TARGET_LINK_LIBRARIES(${SQPMOCKPLUGIN_LIBRARY_NAME} ${LIBRARIES})
53 53 qt5_use_modules(${SQPMOCKPLUGIN_LIBRARY_NAME} Core Widgets)
54 54
55 55 add_dependencies(${SQPMOCKPLUGIN_LIBRARY_NAME} ${SQPPLUGIN_LIBRARY_NAME} ${SQPGUI_LIBRARY_NAME} ${SQPCORE_LIBRARY_NAME})
56 56
57 57 # From cmake documentation: http://www.cmake.org/cmake/help/v3.0/manual/cmake-buildsystem.7.html
58 58 # Entries in the COMPILE_DEFINITIONS are prefixed with -D or /D and added to the compile line in an unspecified order.
59 59 # The DEFINE_SYMBOL target property is also added as a compile definition as a special convenience case for SHARED and MODULE library targets
60 60 IF(BUILD_SHARED_LIBS)
61 61 SET_TARGET_PROPERTIES(${SQPMOCKPLUGIN_LIBRARY_NAME} PROPERTIES COMPILE_DEFINITIONS "SCIQLOP_EXPORT")
62 62 ELSE()
63 63 TARGET_COMPILE_DEFINITIONS(${SQPMOCKPLUGIN_LIBRARY_NAME} PUBLIC "SCIQLOP_STATIC_LIBRARIES")
64 64 ENDIF()
65 65
66 66 # Set the variable to parent scope so that the other projects can copy the
67 67 # dependent shared libraries
68 68 SCIQLOP_SET_TO_PARENT_SCOPE(SQPMOCKPLUGIN_LIBRARY_NAME)
69 69
70 70 # Copy extern shared libraries to the lib folder
71 71 SCIQLOP_COPY_TO_TARGET(LIBRARY ${SQPMOCKPLUGIN_LIBRARY_NAME} ${EXTERN_SHARED_LIBRARIES})
72 72
73 73 # Add the files to the list of files to be analyzed
74 74 LIST(APPEND CHECKSTYLE_INPUT_FILES ${MODULE_SOURCES})
75 75 SCIQLOP_SET_TO_PARENT_SCOPE(CHECKSTYLE_INPUT_FILES)
76 76 # Vera++ exclusion files
77 77 #LIST(APPEND CHECKSTYLE_EXCLUSION_FILES ${CMAKE_CURRENT_SOURCE_DIR}/vera-exclusions/exclusions.txt)
78 78 SCIQLOP_SET_TO_PARENT_SCOPE(CHECKSTYLE_EXCLUSION_FILES)
79 79
80 # Temporary target to copy to plugins dir
81 find_package(sciqlop-mockplugin)
82 ADD_CUSTOM_TARGET(plugins
83 COMMAND ${CMAKE_COMMAND} -E copy ${SCIQLOP-MOCKPLUGIN_LIBRARIES} "${LIBRARY_OUTPUT_PATH}/plugins/${SCIQLOP-MOCKPLUGIN_LIBRARIES_NAME}"
84 )
85
80 86 #
81 87 # Compile the tests
82 88 #
83 89 IF(BUILD_TESTS)
84 90 INCLUDE_DIRECTORIES(${SOURCES_DIR})
85 91 FILE (GLOB_RECURSE TESTS_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/Test*.cpp)
86 92 FILE (GLOB_RECURSE TESTS_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/Test*.h)
87 93 SET( TEST_LIBRARIES ${SQPGUI_LIBRARY_NAME})
88 94
89 95 FOREACH( testFile ${TESTS_SOURCES} )
90 96 GET_FILENAME_COMPONENT( testDirectory ${testFile} DIRECTORY )
91 97 GET_FILENAME_COMPONENT( testName ${testFile} NAME_WE )
92 98
93 99 # Add to the list of sources files all the sources in the same
94 100 # directory that aren't another test
95 101 FILE (GLOB currentTestSources
96 102 ${testDirectory}/*.c
97 103 ${testDirectory}/*.cpp
98 104 ${testDirectory}/*.h)
99 105 LIST (REMOVE_ITEM currentTestSources ${TESTS_SOURCES})
100 106 # LIST (REMOVE_ITEM currentTestSources ${TESTS_HEADERS})
101 107
102 108 ADD_EXECUTABLE(${testName} ${testFile} ${currentTestSources})
103 109 set_property(TARGET ${testName} PROPERTY CXX_STANDARD 14)
104 110 set_property(TARGET ${testName} PROPERTY CXX_STANDARD_REQUIRED ON)
105 111 TARGET_LINK_LIBRARIES( ${testName} ${TEST_LIBRARIES} )
106 112 qt5_use_modules(${testName} Test)
107 113
108 114 ADD_TEST( NAME ${testName} COMMAND ${testName} )
109 115
110 116 SCIQLOP_COPY_TO_TARGET(RUNTIME ${testName} ${EXTERN_SHARED_LIBRARIES})
111 117 ENDFOREACH( testFile )
112 118
113 119 LIST(APPEND testFilesToFormat ${TESTS_SOURCES})
114 120 LIST(APPEND testFilesToFormat ${TESTS_HEADERS})
115 121 LIST(APPEND FORMATTING_INPUT_FILES ${testFilesToFormat})
116 122 SCIQLOP_SET_TO_PARENT_SCOPE(FORMATTING_INPUT_FILES)
117 123 ENDIF(BUILD_TESTS)
118 124
119 125 #
120 126 # Set the files that must be formatted by clang-format.
121 127 #
122 128 LIST (APPEND FORMATTING_INPUT_FILES ${MODULE_SOURCES})
123 129 SCIQLOP_SET_TO_PARENT_SCOPE(FORMATTING_INPUT_FILES)
124 130
125 131 #
126 132 # Set the directories that doxygen must browse to generate the
127 133 # documentation.
128 134 #
129 135 # Source directories:
130 136 LIST (APPEND DOXYGEN_INPUT_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/docs")
131 137 LIST (APPEND DOXYGEN_INPUT_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/src")
132 138 SCIQLOP_SET_TO_PARENT_SCOPE(DOXYGEN_INPUT_DIRS)
133 139 # Source directories to exclude from the documentation generation
134 140 #LIST (APPEND DOXYGEN_EXCLUDE_PATTERNS "${CMAKE_CURRENT_SOURCE_DIR}/path/to/subdir/*")
135 141 SCIQLOP_SET_TO_PARENT_SCOPE(DOXYGEN_EXCLUDE_PATTERNS)
136 142
137 143 #
138 144 # Set the directories with the sources to analyze and propagate the
139 145 # modification to the parent scope
140 146 #
141 147 # Source directories to analyze:
142 148 LIST (APPEND ANALYSIS_INPUT_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/src")
143 149 LIST (APPEND ANALYSIS_INPUT_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/tests")
144 150 SCIQLOP_SET_TO_PARENT_SCOPE(ANALYSIS_INPUT_DIRS)
145 151 # Source directories to exclude from the analysis
146 152 #LIST (APPEND ANALYSIS_EXCLUDE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/path/to/subdir")
147 153 SCIQLOP_SET_TO_PARENT_SCOPE(ANALYSIS_EXCLUDE_DIRS)
@@ -1,21 +1,22
1 1 # - Try to find sciqlop-mockplugin
2 2 # Once done this will define
3 3 # SCIQLOP-MOCKPLUGIN_FOUND - System has sciqlop-mockplugin
4 4 # SCIQLOP-MOCKPLUGIN_INCLUDE_DIR - The sciqlop-mockplugin include directories
5 5 # SCIQLOP-MOCKPLUGIN_LIBRARIES - The libraries needed to use sciqlop-mockplugin
6 6
7 7 if(SCIQLOP-MOCKPLUGIN_FOUND)
8 8 return()
9 9 endif(SCIQLOP-MOCKPLUGIN_FOUND)
10 10
11 11 set(SCIQLOP-MOCKPLUGIN_INCLUDE_DIR ${sciqlop-mockplugin_DIR}/../include)
12 12
13 13 set (OS_LIB_EXTENSION "so")
14 14
15 15 if(WIN32)
16 16 set (OS_LIB_EXTENSION "dll")
17 17 endif(WIN32)
18 18 # TODO: Add Mac Support
19 set(SCIQLOP-MOCKPLUGIN_LIBRARIES ${LIBRARY_OUTPUT_PATH}/libsciqlop_mockplugin${DEBUG_SUFFIX}.${OS_LIB_EXTENSION})
19 set(SCIQLOP-MOCKPLUGIN_LIBRARIES_NAME "libsciqlop_mockplugin${DEBUG_SUFFIX}.${OS_LIB_EXTENSION}")
20 set(SCIQLOP-MOCKPLUGIN_LIBRARIES "${LIBRARY_OUTPUT_PATH}/${SCIQLOP-MOCKPLUGIN_LIBRARIES_NAME}")
20 21
21 22 set(SCIQLOP-MOCKPLUGIN_FOUND TRUE)
General Comments 0
You need to be logged in to leave comments. Login now