Skip to content

Commit

Permalink
Fix for GTEST on windows
Browse files Browse the repository at this point in the history
Fix for GTEST on windows

Fix for GTEST on windows

Fix for GTEST on windows

Fix for GTEST on windows

Fix for GTEST on windows

Fix for GTEST on windows

Fix for GTEST on windows

Fix for GTEST on windows

Fix for GTEST on windows
  • Loading branch information
ihedvall committed Jan 25, 2024
1 parent b0126d6 commit 3e33606
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 27 deletions.
17 changes: 10 additions & 7 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,14 @@ jobs:
with:
platform: ${{ matrix.env.ninja_platform }}

- name: GTEST Install
uses: MarkusJx/googletest-installer@master
- name: PYTHON Install
uses: actions/setup-python@main

- name: PYTEST Install
run: pip install pytest

run: |
python -m pip install --upgrade pip
python -m pip install pytest
- name: CMAKE Configure
env: ${{ matrix.env.cmake_env }}
run: cmake -G Ninja -B ${{github.workspace}}/build -D DBC_TEST=ON -D DBC_PYTHON=ON
Expand All @@ -78,20 +80,21 @@ jobs:
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}

- name: CTEST Unit Test
if: ${{ matrix.env.ninja_platform != 'win'}}
working-directory: ${{github.workspace}}/build
# Execute tests defined by the CMake configuration.
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
run: ctest -C ${{env.BUILD_TYPE}}
run: ctest -C ${{env.BUILD_TYPE}} --extra-verbose --output-on-failure

# install for testing
# - name: Install
# run: >
# run: |
# cd ${{github.workspace}}/build/release
# sudo cmake --install .

# test if cmake finds the dbcLib automatically
# - name: TestInstall
# run: >
# run: |
# cd test/TestdbclibCMake
# mkdir -p build
# cd build
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ if (wxWidgets_FOUND AND DBC_TOOLS)
add_subdirectory(dbcviewer)
endif ()

if (GTEST_FOUND AND DBC_TEST)
if (DBC_TEST)
enable_testing()
add_subdirectory(test)
endif ()
Expand Down
26 changes: 14 additions & 12 deletions script/googletest.cmake
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
# Copyright 2021 Ingemar Hedvall
# SPDX-License-Identifier: MIT

if (NOT GTest_FOUND)
set(GTEST_MSVC_SEARCH MT)
if (COMP_DIR)
set(GTEST_ROOT ${COMP_DIR}/googletest/master)
endif()
include (FetchContent)

message(STATUS "GTest Fetching: " ${GTest_FOUND})
include(FetchContent)
FetchContent_Declare(googletest
GIT_REPOSITORY https://github.com/google/googletest.git
GIT_TAG HEAD
)
# For Windows: Prevent overriding the parent project's compiler/linker settings
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
FetchContent_MakeAvailable(googletest)
message(STATUS "googletest Populated: " ${googletest_POPULATED})
message(STATUS "googletest Source: " ${googletest_SOURCE_DIR})
message(STATUS "googletest Binary: " ${googletest_BINARY_DIR})

find_package(GTest)
message(STATUS "GTest Found: " ${GTest_FOUND})
message(STATUS "GTest Include Dirs: " ${GTEST_INCLUDE_DIRS})
message(STATUS "GTest Libraries: " ${GTEST_LIBRARIES})
message(STATUS "GTest Main Libraries: " ${GTEST_MAIN_LIBRARIES})
message(STATUS "GTest Both Libraries: " ${GTEST_BOTH_LIBRARIES})
endif()
9 changes: 2 additions & 7 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@ add_executable(test_dbc
test_dbchelper.cpp)

target_include_directories(test_dbc PRIVATE
../src # dbchelper.h
${GTEST_INCLUDE_DIRS}
${Boost_INCLUDE_DIRS})
../src )

if (MINGW)
target_link_options(test_dbc PRIVATE -static -fstack-protector)
Expand All @@ -23,10 +21,7 @@ elseif (MSVC)
endif ()

target_link_libraries(test_dbc PRIVATE dbc)
target_link_libraries(test_dbc PRIVATE ${GTEST_BOTH_LIBRARIES})

if (WIN32)
endif ()
target_link_libraries(test_dbc PRIVATE GTest::gtest_main)

include(GoogleTest)
gtest_discover_tests(test_dbc)
Expand Down

0 comments on commit 3e33606

Please sign in to comment.