From 23a4c64787f67561c4d1ae2db60bca516ea19224 Mon Sep 17 00:00:00 2001 From: Deukhoofd Date: Tue, 31 Dec 2019 18:41:41 +0100 Subject: [PATCH] Maybe a fix for the issue with tests not linking properly --- .drone.yml | 4 ++-- CMakeLists.txt | 18 ++++++++++++------ 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/.drone.yml b/.drone.yml index b463a57..0024877 100644 --- a/.drone.yml +++ b/.drone.yml @@ -19,7 +19,7 @@ steps: CXX: clang++ commands: - conan remote add epsilon-public https://packages.p-epsilon.com/artifactory/api/conan/epsilon-public - - cmake -DCMAKE_BUILD_TYPE=Debug . -B build-debug + - cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_COMPILER=/usr/bin/clang -DCMAKE_CXX_COMPILER=/usr/bin/clang++ . -B build-debug - cmake --build build-debug --target all -- -j 4 - build-debug/bin/pkmnLibtests -s --durations yes --use-colour yes - name: test-release-linux @@ -32,7 +32,7 @@ steps: CXX: clang++ commands: - conan remote add epsilon-public https://packages.p-epsilon.com/artifactory/api/conan/epsilon-public - - cmake -DCMAKE_BUILD_TYPE=Release . -B build-release + - cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=/usr/bin/clang -DCMAKE_CXX_COMPILER=/usr/bin/clang++ . -B build-release - cmake --build build-release --target all -- -j 4 - build-release/bin/pkmnLibtests -s --durations yes --use-colour yes - valgrind --tool=memcheck --gen-suppressions=all --leak-check=full --leak-resolution=med --track-origins=yes --vgdb=no --error-exitcode=1 build-release/CreatureLibTests diff --git a/CMakeLists.txt b/CMakeLists.txt index d5428d0..86a2f97 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,14 +12,20 @@ if (WINDOWS) ADD_DEFINITIONS(-D WINDOWS=1) endif(WINDOWS) -message(STATUS "Using ${CMAKE_CXX_COMPILER}") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libstdc++") + +message(STATUS "Using: +\t C ${CMAKE_C_COMPILER} +\t C++ ${CMAKE_CXX_COMPILER} +\t CXX ABI ${CMAKE_CXX_COMPILER_ABI} +\t C++ Version ${CMAKE_CXX_STANDARD}") + + if (NOT EXISTS ${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) message(WARNING "The file conanbuildinfo.cmake doesn't exist, running conan install.") string(REPLACE "." ";" VERSION_LIST "${CMAKE_CXX_COMPILER_VERSION}") list(GET VERSION_LIST 0 MAJOR) - execute_process(COMMAND conan install ${CMAKE_SOURCE_DIR} --install-folder=${CMAKE_BINARY_DIR} --build missing -s compiler=clang -s compiler.libcxx=libstdc++ -s compiler.version=${MAJOR}) + execute_process(COMMAND conan install ${CMAKE_SOURCE_DIR} --install-folder=${CMAKE_BINARY_DIR} --build CreatureLib -s compiler=clang -s compiler.libcxx=libstdc++11 -s compiler.version=${MAJOR}) endif () include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) conan_basic_setup() @@ -28,19 +34,19 @@ conan_basic_setup() # Create Core library with files in src/Core file(GLOB_RECURSE CORE_SRC_FILES "src/*.cpp" "src/*.hpp") add_library(pkmnLib SHARED ${CORE_SRC_FILES}) - +set(CMAKE_VERBOSE_MAKEFILE ON) foreach (_variableName ${CONAN_LIBS}) message(STATUS "Lib: ${_variableName}") endforeach() -target_link_libraries(pkmnLib ${CONAN_LIBS}) +target_link_libraries(pkmnLib PUBLIC ${CONAN_LIBS}) if (NOT DEFINED CONAN_EXPORTED) # Create Test executable file(GLOB_RECURSE TEST_FILES "tests/*.cpp" "tests/*.hpp") add_executable(pkmnLibTests ${TEST_FILES} extern/catch.hpp) - target_link_libraries(pkmnLibTests ${CONAN_LIBS} pkmnLib) + target_link_libraries(pkmnLibTests PUBLIC ${CONAN_LIBS} pkmnLib) # Add a definition for the test library target_compile_definitions(pkmnLibTests PRIVATE TESTS_BUILD)