ResInsight/ThirdParty/custom-opm-common/custom-opm-parser-tests/CMakeLists.txt
jonjenssen 5391179e16
Add separate target for unit tests for easier test access. Remove unit tests from ResInsight application. (#11184)
Clean up cmake configuration a bit, and pull down gtest when needed, no longer use a thirdparty subfolder
Add a ResInsight-tests target to run the unit tests
2024-02-11 20:04:04 +01:00

45 lines
1.2 KiB
CMake

project ( opm-parser-tests )
include(FetchContent)
FetchContent_Declare(
googletest
GIT_REPOSITORY https://github.com/google/googletest.git
GIT_TAG release-1.11.0
)
FetchContent_MakeAvailable(googletest)
set(THREADS_PREFER_PTHREAD_FLAG ON)
set( PROJECT_FILES opm-parser-BasicTest.cpp )
# add the executable
add_executable (${PROJECT_NAME} ${PROJECT_FILES} )
# Languages and global compiler settings
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
if (MSVC AND (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 19.11))
# VS 2017 : Disable warnings from from gtest code, using deprecated code related to TR1
add_definitions(-D_SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING)
endif()
CONFIGURE_FILE( ${CMAKE_CURRENT_LIST_DIR}/OpmTestDataDirectory.h.cmake
${CMAKE_BINARY_DIR}/Generated/OpmTestDataDirectory.h
)
target_include_directories (${PROJECT_NAME} PUBLIC ${CMAKE_BINARY_DIR}/Generated )
target_link_libraries ( ${PROJECT_NAME}
custom-opm-common
GTest::gtest_main
)
# Add dependency of Shlwapi.lib for Windows platforms
if (MSVC)
target_link_libraries(${PROJECT_NAME} Shlwapi)
endif()
add_test(NAME ${PROJECT_NAME} COMMAND ${PROJECT_NAME})