-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
98 lines (80 loc) Β· 3.4 KB
/
CMakeLists.txt
File metadata and controls
98 lines (80 loc) Β· 3.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
############################################################################
# Copyright (c) 2017, Sylvain Corlay, Johan Mabille, and Loic Gouarin #
# #
# Distributed under the terms of the BSD 3-Clause License. #
# #
# The full license is in the file LICENSE, distributed with this software. #
############################################################################
cmake_minimum_required(VERSION 3.8)
message(STATUS "Forcing tests build type to Release")
set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build." FORCE)
if (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
project(xplot-test)
find_package(xplot REQUIRED CONFIG)
set(XPLOT_INCLUDE_DIR ${xplot_INCLUDE_DIRS})
endif ()
# Dependencies
# ============
if(DOWNLOAD_GTEST OR GTEST_SRC_DIR)
if(DOWNLOAD_GTEST)
# Download and unpack googletest at configure time
configure_file(downloadGTest.cmake.in googletest-download/CMakeLists.txt)
else()
# Copy local source of googletest at configure time
configure_file(copyGTest.cmake.in googletest-download/CMakeLists.txt)
endif()
execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" .
RESULT_VARIABLE result
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/googletest-download )
if(result)
message(FATAL_ERROR "CMake step for googletest failed: ${result}")
endif()
execute_process(COMMAND ${CMAKE_COMMAND} --build .
RESULT_VARIABLE result
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/googletest-download )
if(result)
message(FATAL_ERROR "Build step for googletest failed: ${result}")
endif()
# Add googletest directly to our build. This defines
# the gtest and gtest_main targets.
add_subdirectory(${CMAKE_CURRENT_BINARY_DIR}/googletest-src
${CMAKE_CURRENT_BINARY_DIR}/googletest-build EXCLUDE_FROM_ALL)
set(GTEST_INCLUDE_DIRS "${gtest_SOURCE_DIR}/include")
set(GTEST_BOTH_LIBRARIES gtest_main gtest)
else()
find_package(GTest REQUIRED)
endif()
find_package(Threads)
# Source files
# ============
include_directories(${XPLOT_INCLUDE_DIR})
include_directories(${GTEST_INCLUDE_DIRS})
set(XPLOT_TESTS
main.cpp
test_xaxes.cpp
test_xfigure.cpp
test_xmarks.cpp
test_xtoolbar.cpp
)
# Output
# ======
set(CMAKE_SKIP_BUILD_RPATH FALSE)
set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}")
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
list(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${CMAKE_INSTALL_PREFIX}/lib" isSystemDir)
if("${isSystemDir}" STREQUAL "-1")
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
endif("${isSystemDir}" STREQUAL "-1")
add_executable(test_xplot ${XPLOT_TESTS} ${XPLOT_HEADERS})
if(DOWNLOAD_GTEST OR GTEST_SRC_DIR)
add_dependencies(test_xplot gtest_main)
endif()
target_compile_features(test_xplot PRIVATE cxx_std_14)
target_link_libraries(test_xplot
PUBLIC xtl
PUBLIC xeus
PUBLIC xwidgets
PUBLIC xplot
PRIVATE ${GTEST_BOTH_LIBRARIES}
PRIVATE ${CMAKE_THREAD_LIBS_INIT})