From 5087348a372d1e2abc4c7266ddbef5018d558c5c Mon Sep 17 00:00:00 2001 From: Rahul Sheth Date: Tue, 25 Aug 2020 11:30:46 -0400 Subject: [PATCH] Build tests and tools with Hunter --- Dockerfile | 26 ++++++++++++++++++++++++++ test/CMakeLists.txt | 22 +++++++++++++++++----- 2 files changed, 43 insertions(+), 5 deletions(-) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 000000000..fa6837d29 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,26 @@ +FROM ubuntu:20.04 + +ARG TOOLCHAIN_NAME=gcc-9-cxx17-fpic +ARG BUILD_TYPE=RelWithDebInfo + +RUN apt-get update && apt-get install -y --no-install-recommends \ + cmake \ + gcc-9 \ + g++-9 \ + ca-certificates \ + make + +WORKDIR /root/assimp +COPY ./cmake ./cmake +COPY ./cmake-modules ./cmake-modules +COPY ./code ./code +COPY ./include ./include +COPY ./samples ./samples +COPY ./test ./test +COPY ./tools ./tools +COPY ./*.in ./ +COPY CMakeLists.txt ./ + +RUN cmake -DBUILD_SHARED_LIBS=OFF -DASSIMP_BUILD_ASSIMP_TOOLS=ON -DASSIMP_BUILD_SAMPLES=OFF -DASSIMP_BUILD_TESTS=ON -DASSIMP_INSTALL_PDB=OFF -DASSIMP_IGNORE_GIT_HASH=ON -DASSIMP_HUNTER_ENABLED=ON -H. -B_builds/${TOOLCHAIN_NAME}-${BUILD_TYPE} -DCMAKE_TOOLCHAIN_FILE=./cmake/polly/${TOOLCHAIN_NAME}.cmake -DCMAKE_BUILD_TYPE=${BUILD_TYPE} + +RUN make -C _builds/${TOOLCHAIN_NAME}-${BUILD_TYPE} -j 4 diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 5a150482d..0d038943e 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -39,12 +39,18 @@ cmake_minimum_required( VERSION 3.0 ) INCLUDE_DIRECTORIES( - ${Assimp_SOURCE_DIR}/contrib/gtest/include - ${Assimp_SOURCE_DIR}/contrib/gtest/ ${Assimp_SOURCE_DIR}/test/unit ${Assimp_SOURCE_DIR}/include ${Assimp_SOURCE_DIR}/code ) + +if(NOT ASSIMP_HUNTER_ENABLED) + INCLUDE_DIRECTORIES( + ${Assimp_SOURCE_DIR}/contrib/gtest/include + ${Assimp_SOURCE_DIR}/contrib/gtest/ + ) +endif() + if (MSVC) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D_SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING") endif() @@ -197,7 +203,6 @@ SOURCE_GROUP( UnitTests\\Math FILES ${MATH} ) SOURCE_GROUP( UnitTests\\PostProcess FILES ${POST_PROCESSES}) add_executable( unit - ../contrib/gtest/src/gtest-all.cc unit/CCompilerTest.c unit/Main.cpp ../code/Common/Version.cpp @@ -208,6 +213,14 @@ add_executable( unit ${POST_PROCESSES} ) +if(ASSIMP_HUNTER_ENABLED) + hunter_add_package(GTest) + find_package(GTest CONFIG REQUIRED) + target_link_libraries(unit GTest::gtest_main GTest::gmock) +else() + target_sources(unit PUBLIC ../contrib/gtest/src/gtest-all.cc) +endif() + TARGET_USE_COMMON_OUTPUT_DIRECTORY(unit) add_definitions(-DASSIMP_TEST_MODELS_DIR="${CMAKE_CURRENT_LIST_DIR}/models") @@ -222,7 +235,7 @@ ELSE() ENDIF() IF(MSVC) - add_definitions(-D_CRT_SECURE_NO_WARNINGS) + add_definitions(-D_CRT_SECURE_NO_WARNINGS) ENDIF() target_link_libraries( unit assimp ${platform_libs} ) @@ -230,4 +243,3 @@ target_link_libraries( unit assimp ${platform_libs} ) add_subdirectory(headercheck) add_test( unittests unit ) -