Skip to content

Commit 8662c39

Browse files
committed
Review configure setup
1 parent 9fce4d4 commit 8662c39

File tree

265 files changed

+70
-118032
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

265 files changed

+70
-118032
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,5 @@ build/
3939

4040
# build directories
4141
build
42+
*-build*
4243
build-*

cmake/Findgoogletest.cmake

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
2+
# googletest_FOUND
3+
# Target googletest::googletest
4+
5+
include(FindPackageHandleStandardArgs)
6+
7+
find_package(PkgConfig)
8+
pkg_search_module(GMOCK QUIET gmock_main)
9+
10+
find_package_handle_standard_args(googletest REQUIRED_VARS GMOCK_CFLAGS GMOCK_LDFLAGS)
11+
mark_as_advanced(GMOCK_CFLAGS GMOCK_LDFLAGS)
12+
13+
if (googletest_FOUND)
14+
15+
16+
# Create interface library to link against gmock
17+
add_library(googletest::googletest INTERFACE IMPORTED)
18+
19+
target_link_libraries(googletest::googletest
20+
INTERFACE
21+
${GMOCK_LDFLAGS}
22+
)
23+
24+
target_compile_options(googletest::googletest
25+
INTERFACE
26+
${GMOCK_CFLAGS}
27+
)
28+
endif ()

configure

+21-7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#!/bin/bash
22

33
# Default options
4+
45
BUILD_DIR="build"
56
CMAKE_GENERATOR="Unix Makefiles"
67
BUILD_TYPE="Release"
@@ -99,19 +100,33 @@ do
99100
fi
100101
done
101102

103+
if [ "$CMAKE_GENERATOR_OVERRIDE" != "" ]
104+
then
105+
echo "Override CMAKE_GENERATOR to $CMAKE_GENERATOR_OVERRIDE"
106+
CMAKE_GENERATOR="$CMAKE_GENERATOR_OVERRIDE"
107+
fi
108+
109+
if [ -n "$BUILD_DIR_PREFIX" ]; then
110+
BUILD_DIR="${BUILD_DIR_PREFIX}-${BUILD_DIR}"
111+
fi
112+
102113
# Configure build
103-
echo "Configuring ..."
114+
echo "Configuring in \"$BUILD_DIR\""
104115
echo ""
105116

106117
# Create build directory
107-
if [ ! -d "./$BUILD_DIR" ]
118+
if [ ! -d "$BUILD_DIR" ]
108119
then
109-
mkdir $BUILD_DIR
120+
mkdir -p "$BUILD_DIR"
110121
fi
111122

112123
# Configure project
113-
cd $BUILD_DIR
114-
cmake -G "$CMAKE_GENERATOR" "-DCMAKE_BUILD_TYPE=$BUILD_TYPE" $CMAKE_OPTIONS ..
124+
125+
PREVIOUS_DIR=$(pwd)
126+
127+
pushd $BUILD_DIR
128+
echo cmake -G "$CMAKE_GENERATOR" "-DCMAKE_BUILD_TYPE=$BUILD_TYPE" $CMAKE_OPTIONS "$PREVIOUS_DIR"
129+
cmake -G "$CMAKE_GENERATOR" "-DCMAKE_BUILD_TYPE=$BUILD_TYPE" $CMAKE_OPTIONS "$PREVIOUS_DIR"
115130
if [ $? == 0 ]
116131
then
117132
echo ""
@@ -122,5 +137,4 @@ else
122137
echo ""
123138
echo "Configuration failed.";
124139
fi
125-
126-
cd ..
140+
popd

source/tests/CMakeLists.txt

+17-28
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,9 @@ set(META_PROJECT_NAME "glkernel")
1313
project("${META_PROJECT_NAME}-tests" C CXX)
1414

1515
# Set policies
16-
set_policy(CMP0028 NEW) # ENABLE CMP0028: Double colon in target name means ALIAS or IMPORTED target.
1716
set_policy(CMP0054 NEW) # ENABLE CMP0054: Only interpret if() arguments as variables or keywords when unquoted.
1817
set_policy(CMP0042 NEW) # ENABLE CMP0042: MACOSX_RPATH is enabled by default.
1918
set_policy(CMP0063 NEW) # ENABLE CMP0063: Honor visibility properties for all target types.
20-
set_policy(CMP0037 OLD) # DISABLE CMP0037: Target names should not be reserved and should match a validity pattern.
2119

2220
# Compiler settings and options
2321

@@ -41,40 +39,31 @@ function(add_test_without_ctest target)
4139

4240
add_dependencies(test ${target})
4341
add_custom_command(TARGET test POST_BUILD
44-
COMMAND $<TARGET_FILE:${target}> --gtest_output=xml:gtests-${target}.xml)
42+
COMMAND $<TARGET_FILE:${target}> --gtest_output=xml:gtests-${target}.xml
43+
)
4544
endfunction()
4645

47-
# Build gmock
48-
set(gmock_build_tests OFF CACHE BOOL "")
49-
set(gtest_build_samples OFF CACHE BOOL "")
50-
set(gtest_build_tests OFF CACHE BOOL "")
51-
set(gtest_disable_pthreads OFF CACHE BOOL "")
52-
set(gtest_force_shared_crt ON CACHE BOOL "")
53-
set(gtest_hide_internal_symbols OFF CACHE BOOL "")
54-
55-
add_subdirectory(googletest/googlemock)
56-
57-
# Create interface library to link against gmock
58-
add_library(gmock-dev INTERFACE)
59-
60-
target_include_directories(gmock-dev
61-
SYSTEM INTERFACE
62-
${CMAKE_CURRENT_SOURCE_DIR}/googletest/googletest/include
63-
${CMAKE_CURRENT_SOURCE_DIR}/googletest/googlemock/include
64-
)
65-
66-
target_link_libraries(gmock-dev
67-
INTERFACE
68-
gmock
69-
)
46+
find_package(googletest QUIET)
7047

48+
if (NOT TARGET googletest::googletest)
49+
message(STATUS "Tests skipped: googletest not found")
50+
return()
51+
endif ()
7152

7253
#
7354
# Target 'test'
7455
#
7556

76-
add_custom_target(test)
77-
set_target_properties(test PROPERTIES EXCLUDE_FROM_DEFAULT_BUILD 1)
57+
if (${CMAKE_VERSION} VERSION_LESS "3.11")
58+
set_policy(CMP0037 OLD) # DISABLE CMP0037: Target names should be reserved and should match a validity pattern.
59+
add_custom_target(test)
60+
set_target_properties(test PROPERTIES EXCLUDE_FROM_DEFAULT_BUILD 1)
61+
else ()
62+
if (NOT TARGET test)
63+
add_custom_target(test)
64+
set_target_properties(test PROPERTIES EXCLUDE_FROM_DEFAULT_BUILD 1)
65+
endif()
66+
endif ()
7867

7968

8069
#

source/tests/glkernel-test/CMakeLists.txt

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
find_package(${META_PROJECT_NAME} REQUIRED HINTS "${CMAKE_CURRENT_SOURCE_DIR}/../../../")
77

8-
find_package(glm REQUIRED)
8+
find_package(glm CONFIG REQUIRED)
99
find_package(OpenMP QUIET)
1010

1111
#
@@ -71,7 +71,6 @@ set_target_properties(${target}
7171
target_include_directories(${target}
7272
PRIVATE
7373
${DEFAULT_INCLUDE_DIRECTORIES}
74-
${GLM_INCLUDE_DIR}
7574
${PROJECT_BINARY_DIR}/source/include
7675
)
7776

@@ -84,7 +83,8 @@ target_link_libraries(${target}
8483
PRIVATE
8584
${DEFAULT_LIBRARIES}
8685
${META_PROJECT_NAME}::glkernel
87-
gmock-dev
86+
glm::glm
87+
googletest::googletest
8888
)
8989

9090

source/tests/googletest/.gitignore

-24
This file was deleted.

source/tests/googletest/.travis.yml

-74
This file was deleted.

0 commit comments

Comments
 (0)