Skip to content

Commit ac7ea59

Browse files
committed
Make direct source include optional
1 parent 143c6fc commit ac7ea59

File tree

8 files changed

+31
-21
lines changed

8 files changed

+31
-21
lines changed

CMakeLists.txt

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ SET ( CPPCORE_VERSION_PATCH 0 )
66
SET ( CPPCORE_VERSION ${CPPCORE_VERSION_MAJOR}.${CPPCORE_VERSION_MINOR}.${CPPCORE_VERSION_PATCH} )
77
SET ( PROJECT_VERSION "${CPPCORE_VERSION}" )
88

9+
find_package(SDL2 CONFIG REQUIRED)
10+
find_package(GTest)
11+
912
if( CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX )
1013
find_package(Threads)
1114
endif()
@@ -30,8 +33,6 @@ add_definitions( -D_SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING=1)
3033

3134
INCLUDE_DIRECTORIES( BEFORE
3235
include/
33-
contrib/googletest-1.15.2/googletest/include
34-
contrib/googletest-1.15.2/googletest
3536
)
3637

3738
link_directories(
@@ -157,8 +158,6 @@ IF( CPPCORE_BUILD_UNITTESTS )
157158
test/Random/RandomGeneratorTest.cpp
158159
)
159160

160-
SET ( GTEST_PATH ../contrib/googletest-1.15.2 )
161-
162161
SOURCE_GROUP( code FILES ${cppcore_test_src} )
163162
SOURCE_GROUP( code\\common FILES ${cppcore_common_test_src} )
164163
SOURCE_GROUP( code\\container FILES ${cppcore_container_test_src} )
@@ -168,7 +167,18 @@ IF( CPPCORE_BUILD_UNITTESTS )
168167
# Prevent overriding the parent project's compiler/linker
169168
# settings on Windows
170169
SET(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
171-
ADD_SUBDIRECTORY( contrib/googletest-1.15.2/ )
170+
if (GTest_FOUND)
171+
SET(test_libs GTest::gtest_main)
172+
else()
173+
SET(test_libs gtest_main)
174+
SET ( GTEST_PATH ../contrib/googletest-1.15.2 )
175+
INCLUDE_DIRECTORIES(
176+
contrib/googletest-1.15.2/googletest/include
177+
contrib/googletest-1.15.2/googletest
178+
)
179+
ADD_SUBDIRECTORY( contrib/googletest-1.15.2/ )
180+
endif()
181+
172182
ADD_EXECUTABLE( cppcore_unittest
173183
${cppcore_test_src}
174184
${cppcore_common_test_src}
@@ -182,5 +192,5 @@ IF( CPPCORE_BUILD_UNITTESTS )
182192
ELSE( WIN32 )
183193
SET( platform_libs pthread )
184194
ENDIF( WIN32 )
185-
target_link_libraries( cppcore_unittest cppcore ${CMAKE_THREAD_LIBS_INIT} gtest_main ${platform_libs} )
195+
target_link_libraries( cppcore_unittest cppcore ${CMAKE_THREAD_LIBS_INIT} ${platform_libs} ${test_libs})
186196
ENDIF()

contrib/googletest-1.15.2/googletest/generated/GTestConfig.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ endmacro()
2424

2525
####################################################################################
2626
include(CMakeFindDependencyMacro)
27-
if (ON)
27+
if ()
2828
set(THREADS_PREFER_PTHREAD_FLAG )
2929
find_dependency(Threads)
3030
endif()
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
libdir=/usr/local/lib
2-
includedir=/usr/local/include
1+
libdir=C:/Program Files (x86)/osre/lib
2+
includedir=C:/Program Files (x86)/osre/include
33

44
Name: gmock
55
Description: GoogleMock (without main() function)
66
Version: 1.15.2
77
URL: https://github.com/google/googletest
88
Requires: gtest = 1.15.2
99
Libs: -L${libdir} -lgmock
10-
Cflags: -I${includedir} -DGTEST_HAS_PTHREAD=1
10+
Cflags: -I${includedir} -DGTEST_HAS_PTHREAD=0
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
libdir=/usr/local/lib
2-
includedir=/usr/local/include
1+
libdir=C:/Program Files (x86)/osre/lib
2+
includedir=C:/Program Files (x86)/osre/include
33

44
Name: gmock_main
55
Description: GoogleMock (with main() function)
66
Version: 1.15.2
77
URL: https://github.com/google/googletest
88
Requires: gmock = 1.15.2
99
Libs: -L${libdir} -lgmock_main
10-
Cflags: -I${includedir} -DGTEST_HAS_PTHREAD=1
10+
Cflags: -I${includedir} -DGTEST_HAS_PTHREAD=0
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
libdir=/usr/local/lib
2-
includedir=/usr/local/include
1+
libdir=C:/Program Files (x86)/osre/lib
2+
includedir=C:/Program Files (x86)/osre/include
33

44
Name: gtest
55
Description: GoogleTest (without main() function)
66
Version: 1.15.2
77
URL: https://github.com/google/googletest
88
Libs: -L${libdir} -lgtest
9-
Cflags: -I${includedir} -DGTEST_HAS_PTHREAD=1
9+
Cflags: -I${includedir} -DGTEST_HAS_PTHREAD=0
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
libdir=/usr/local/lib
2-
includedir=/usr/local/include
1+
libdir=C:/Program Files (x86)/osre/lib
2+
includedir=C:/Program Files (x86)/osre/include
33

44
Name: gtest_main
55
Description: GoogleTest (with main() function)
66
Version: 1.15.2
77
URL: https://github.com/google/googletest
88
Requires: gtest = 1.15.2
99
Libs: -L${libdir} -lgtest_main
10-
Cflags: -I${includedir} -DGTEST_HAS_PTHREAD=1
10+
Cflags: -I${includedir} -DGTEST_HAS_PTHREAD=0

contrib/googletest-1.15.2/googletest/gtest.dir/Debug/gtest.lib.recipe

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<Project>
33
<ProjectOutputs>
44
<ProjectOutput>
5-
<FullPath>C:\develop\projects\cppcore\x64\Debug\ZERO_CHECK</FullPath>
5+
<FullPath>C:\develop\projects\osre\x64\Debug\ZERO_CHECK</FullPath>
66
</ProjectOutput>
77
</ProjectOutputs>
88
<ContentFiles />

contrib/googletest-1.15.2/googletest/gtest_main.dir/Debug/gtest_main.lib.recipe

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<Project>
33
<ProjectOutputs>
44
<ProjectOutput>
5-
<FullPath>C:\develop\projects\cppcore\x64\Debug\ZERO_CHECK</FullPath>
5+
<FullPath>C:\develop\projects\osre\x64\Debug\ZERO_CHECK</FullPath>
66
</ProjectOutput>
77
</ProjectOutputs>
88
<ContentFiles />

0 commit comments

Comments
 (0)