From 244b70b4c8bce27bfb3b5185759e6ab6d9b8bec5 Mon Sep 17 00:00:00 2001 From: Hyunjin Song Date: Tue, 13 Nov 2018 19:33:28 +0900 Subject: [PATCH] Fix building unit tests targetting windows Fixes MSVC's LNK4217 warnings and MinGW errors. --- .circleci/config.yml | 6 ++++++ .travis/script.sh | 4 +--- src/CMakeLists.txt | 9 ++++++--- tests/CMakeLists.txt | 3 +++ 4 files changed, 16 insertions(+), 6 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 95b98c595..54301863d 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -54,6 +54,9 @@ jobs: ../cmake/build_win32.sh make lmms make + - run: + name: Build tests + command: cd build && make tests - *ccache_stats - *save_cache mingw64: @@ -71,6 +74,9 @@ jobs: mkdir build && cd build ../cmake/build_win64.sh make + - run: + name: Build tests + command: cd build && make tests - *ccache_stats - *save_cache linux.gcc: diff --git a/.travis/script.sh b/.travis/script.sh index 9f7e1081f..27e9ec7fb 100755 --- a/.travis/script.sh +++ b/.travis/script.sh @@ -24,12 +24,10 @@ else "$TRAVIS_BUILD_DIR/.travis/$TRAVIS_OS_NAME.$TARGET_OS.script.sh" make -j4 + make tests if [[ $TARGET_OS != win* ]]; then - - make tests tests/tests - fi # Package and upload non-tagged builds diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index cd40ad747..37da8f414 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -116,12 +116,15 @@ TARGET_INCLUDE_DIRECTORIES(lmms PUBLIC ${CMAKE_CURRENT_BINARY_DIR} ) -# GENERATE_EXPORT_HEADER doesn't do this automatically for OBJECT libraries +# CMake doesn't define target_EXPORTS for OBJECT libraries. +# See the documentation of DEFINE_SYMBOL for details. +# Also add LMMS_STATIC_DEFINE for targets linking against it. TARGET_COMPILE_DEFINITIONS(lmmsobjs PRIVATE -Dlmmsobjs_EXPORTS + INTERFACE -DLMMS_STATIC_DEFINE ) TARGET_COMPILE_DEFINITIONS(lmms - PRIVATE -Dlmmsobjs_EXPORTS + PRIVATE $ ) # Set Visual Studio startup project to lmms @@ -389,4 +392,4 @@ ELSE(NOT MSVC) # "${VCPKG_ROOT}/bin/libsoundio.dll" # DESTINATION .) #ENDIF() -ENDIF(NOT MSVC) \ No newline at end of file +ENDIF(NOT MSVC) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 249e38191..c39f8e56e 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -19,5 +19,8 @@ ADD_EXECUTABLE(tests src/tracks/AutomationTrackTest.cpp ) +TARGET_COMPILE_DEFINITIONS(tests + PRIVATE $ +) TARGET_LINK_LIBRARIES(tests ${QT_LIBRARIES} ${QT_QTTEST_LIBRARY}) TARGET_LINK_LIBRARIES(tests ${LMMS_REQUIRED_LIBS})