Skip to content

Commit 75a3d56

Browse files
committed
fix: dev: cleanup googletest bits for consistent paths to gtest libs
Signed-off-by: Stephen L Arnold <sarnold@vctlabs.com>
1 parent 4eb365c commit 75a3d56

File tree

5 files changed

+17
-16
lines changed

5 files changed

+17
-16
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ jobs:
5555
os: ubuntu-22.04
5656
compiler: clang
5757
version: "14"
58-
toxcmd: base
58+
toxcmd: clang
5959

6060
- name: macOS-13-gcc
6161
os: macOS-13
@@ -115,7 +115,7 @@ jobs:
115115
tox -e ${{ matrix.toxcmd }}
116116
117117
- uses: actions/upload-artifact@v4
118-
if: matrix.name == 'ubuntu-20.04-clang'
118+
if: matrix.name == 'ubuntu-22.04-clang-14'
119119
with:
120120
name: src_coverage_data
121121
path: |

.github/workflows/conda-dev.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,19 @@ jobs:
2222
- os: 'ubuntu-22.04'
2323
generator: 'Ninja'
2424
build_type: 'Release'
25+
extra_args: '-DBUILD_SHARED_LIBS=ON -DABC_USE_SONAME=ON '
2526
- os: 'ubuntu-24.04'
2627
generator: 'Ninja'
2728
build_type: 'RelWithDebInfo'
29+
extra_args: '-DBUILD_SHARED_LIBS=ON -DABC_USE_SONAME=ON '
2830
- os: 'macOS-14'
2931
generator: 'Ninja'
3032
build_type: 'Debug'
33+
extra_args: '-DBUILD_SHARED_LIBS=ON -DABC_USE_SONAME=ON '
3134
- os: 'windows-2019'
3235
generator: 'Ninja'
3336
build_type: 'Release'
34-
extra_args: '-DABC_USE_NO_PTHREADS=ON -DABC_USE_NO_READLINE=ON'
37+
extra_args: '-DABC_USE_NO_PTHREADS=ON -DABC_USE_NO_READLINE=ON -DBUILD_SHARED_LIBS=OFF'
3538
env:
3639
OS: ${{ matrix.os }}
3740
PY_VER: ${{ matrix.python-version }}
@@ -87,7 +90,7 @@ jobs:
8790
--build-generator "${{ matrix.generator }}" \
8891
--build-and-test . build \
8992
--build-options ${CMAKE_ARGS} ${{ matrix.extra_args }} \
90-
-DBUILD_SHARED_LIBS=ON -DABC_USE_SONAME=ON -DCMAKE_PREFIX_PATH="$CONDA_PREFIX" \
93+
-DCMAKE_PREFIX_PATH="$CONDA_PREFIX" \
9194
--test-command ctest -V \
9295
--build-config "${{ matrix.build_type }}" \
9396
--rerun-failed --output-on-failure

CMakeLists.txt

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -433,9 +433,9 @@ if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
433433
endif()
434434

435435

436+
set(gtest_force_shared_crt ON CACHE BOOL "Always use msvcrt.dll" FORCE)
436437
if(VENDOR_GTEST)
437438
include(FetchContent)
438-
option(BUILD_GMOCK OFF)
439439
option(INSTALL_GTEST OFF)
440440
FetchContent_Declare(
441441
googletest
@@ -444,21 +444,19 @@ if(VENDOR_GTEST)
444444
#GIT_REPOSITORY https://github.com/google/googletest.git
445445
#GIT_TAG v1.14.0
446446
)
447-
set(gtest_force_shared_crt
448-
ON
449-
CACHE BOOL "" FORCE
450-
)
447+
FetchContent_MakeAvailable(googletest)
448+
include_directories(${gtest_INCLUDE_DIRS})
451449
endif()
452450

453451
if(BUILD_TESTING)
454452
if(NOT VENDOR_GTEST)
455-
find_package(GTest REQUIRED)
456-
else()
457-
FetchContent_MakeAvailable(googletest)
453+
find_package(GTest)
454+
include_directories(${GTEST_INCLUDE_DIRS})
458455
endif()
456+
set(GTEST_LINK_LIBRARIES GTest::gtest GTest::gtest_main)
457+
459458
message(STATUS "test discovery enabled")
460459
include(GoogleTest)
461-
set(GTEST_LIBS gtest_main gtest "${CMAKE_THREAD_LIBS_INIT}")
462460

463461
set(test_SRCS src/demo.c)
464462
if(ABC_USE_NAMESPACE)
@@ -467,7 +465,7 @@ if(BUILD_TESTING)
467465
add_executable(base_test ${test_SRCS})
468466
target_compile_options(base_test PUBLIC ${GTEST_CFLAGS})
469467
target_link_libraries(
470-
base_test PUBLIC libabc ${GTEST_LIBS}
468+
base_test PUBLIC libabc ${GTEST_LINK_LIBRARIES}
471469
)
472470

473471
enable_testing()

test/gia/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ target_include_directories(gia_test PUBLIC ${GTEST_INCLUDE_DIRS})
88
target_compile_options(gia_test PUBLIC ${GTEST_CFLAGS})
99
target_link_libraries(gia_test PUBLIC
1010
libabc
11-
${GTEST_LIBS}
11+
${GTEST_LINK_LIBRARIES}
1212
)
1313

1414
gtest_discover_tests(gia_test

tox.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ commands =
8686
clang: lcov_cobertura {toxinidir}/build/coverage/lcov.info --base-dir {toxinidir}/src --output coverage.xml
8787
{base,libs}: cmake --build . --target install
8888
{base,libs}: bash -c 'find $PREFIX/ -type f -name \*abc\* -o -name demo | xargs ls -lh'
89-
ctest: ctest -j {env:CPUS} --build-generator {posargs:"Ninja"} --build-and-test . build --build-options -DABC_USE_NAMESPACE={env:ABC_USE_NAMESPACE} -DABC_SKIP_EXE=ON -DCMAKE_BUILD_TYPE={env:BUILD_TYPE} --test-command ctest --rerun-failed --output-on-failure -V
89+
ctest: ctest -j {env:CPUS} --build-generator {posargs:"Ninja"} --build-and-test . build --build-options -DABC_USE_NAMESPACE={env:ABC_USE_NAMESPACE} -DABC_SKIP_EXE=ON -DCMAKE_BUILD_TYPE={env:BUILD_TYPE} --test-command ctest -C {env:BUILD_TYPE} --rerun-failed --output-on-failure -V
9090
ctestwin: ctest --build-generator {posargs:"Visual Studio 16 2019"} --build-and-test . build --build-options -DVENDOR_GTEST=ON -DBUILD_SHARED_LIBS=ON -DABC_USE_NO_PTHREADS=ON -DABC_USE_NO_READLINE=ON -DCMAKE_BUILD_TYPE={env:BUILD_TYPE} --test-command ctest -C {env:BUILD_TYPE} --rerun-failed --output-on-failure -V
9191
ctest: bash -c 'ls -lh build/*abc* || true'
9292
lint: bash -c 'cpplint --output=gsed {toxinidir}/src/base/main/* {toxinidir}/lib/*'

0 commit comments

Comments
 (0)