Skip to content

Commit

Permalink
Fix for apple clang build issue for GTest
Browse files Browse the repository at this point in the history
  • Loading branch information
nawaz1991 committed Jun 15, 2024
1 parent 17f090a commit 733b7de
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 15 deletions.
25 changes: 13 additions & 12 deletions cmake/FindGTestSrc.cmake
Original file line number Diff line number Diff line change
@@ -1,26 +1,27 @@

SET(GTEST_SEARCH_PATH
"${GTEST_SOURCE_DIR}"
"${CMAKE_CURRENT_LIST_DIR}/../thirdparty/googletest/googletest")
"${CMAKE_CURRENT_LIST_DIR}/../thirdparty/googletest/googletest"
"${GTEST_SOURCE_DIR}"
)

IF(UNIX)
LIST(APPEND GTEST_SEARCH_PATH "/usr/src/gtest")
ENDIF()

FIND_PATH(GTEST_SOURCE_DIR
NAMES CMakeLists.txt src/gtest_main.cc
PATHS ${GTEST_SEARCH_PATH})

NAMES CMakeLists.txt src/gtest_main.cc
PATHS ${GTEST_SEARCH_PATH}
NO_DEFAULT_PATH)

# Debian installs gtest include directory in /usr/include, thus need to look
# for include directory separately from source directory.
FIND_PATH(GTEST_INCLUDE_DIR
NAMES gtest/gtest.h
PATH_SUFFIXES include
HINTS ${GTEST_SOURCE_DIR}
PATHS ${GTEST_SEARCH_PATH})
NAMES gtest/gtest.h
PATH_SUFFIXES include
HINTS ${GTEST_SOURCE_DIR}
PATHS ${GTEST_SEARCH_PATH}
NO_DEFAULT_PATH)

INCLUDE(FindPackageHandleStandardArgs)
find_package_handle_standard_args(GTestSrc DEFAULT_MSG
GTEST_SOURCE_DIR
GTEST_INCLUDE_DIR)
GTEST_SOURCE_DIR
GTEST_INCLUDE_DIR)
6 changes: 3 additions & 3 deletions test/unittest/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ project(${OASVALIDATOR}-unittests LANGUAGES CXX)

set(GOOGLETEST_VERSION 1.14.0)

find_package(GTestSrc)
# Include the custom FindGTestSrc.cmake script
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../cmake")
find_package(GTestSrc REQUIRED)

IF (GTESTSRC_FOUND)
enable_testing()
Expand All @@ -17,7 +19,6 @@ IF (GTESTSRC_FOUND)

set(TEST_LIBRARIES gtest gtest_main)


file(GLOB_RECURSE SOURCES "src/*.cpp")

find_program(CCACHE_FOUND ccache)
Expand All @@ -29,7 +30,6 @@ IF (GTESTSRC_FOUND)
endif ()
endif (CCACHE_FOUND)


add_executable(${PROJECT_NAME} ${SOURCES})

target_include_directories(${PROJECT_NAME}
Expand Down

0 comments on commit 733b7de

Please sign in to comment.