remove cmake option enable-tests

Always build unit tests instead and use cmakes OBJECT library to bypass visibility control and the value of BUILD_SHARED_LIBS.
This commit is contained in:
derselbst 2018-08-05 17:55:07 +02:00
parent 063ab5d7d2
commit 521e5451fc
7 changed files with 23 additions and 29 deletions

View File

@ -57,8 +57,7 @@ build_script:
- cd build
- cmake -G "%generator%" %CMAKE_FLAGS% -Denable-pkgconfig=0 -DCMAKE_TOOLCHAIN_FILE=c:/Tools/vcpkg/scripts/buildsystems/vcpkg.cmake ..
- cmake --build . --config Release # build libfluidsynth and fluidsynth exec
- cmake -Denable-tests=1 ..
- cmake --build . --config Release --target check # build unittests
- cmake --build . --config Release --target check # build and exec unittests
after_build:
- 7z a fluidsynth-vcpkg-%platform%.zip %APPVEYOR_BUILD_FOLDER%\build\src\Release\*

View File

@ -72,10 +72,8 @@ build_script:
- mkdir build
- cd build
- cmake -G "%generator%" ..
- cmake --build . --config Release # build libfluidsynth and fluidsynth exec
# FIXME the linker doesnt find gthread-2.0.lib in the second run, why???
# - cmake -Denable-tests=1 ..
# - cmake --build . --config Release --target check # build unittests
- cmake --build . --config Release
- cmake --build . --config Release --target check # build and exec unittests
after_build:
- 7z a fluidsynth-%platform%.zip %APPVEYOR_BUILD_FOLDER%\build\src\Release\* c:\deps\bin\libglib*.dll c:\deps\bin\libgthread*.dll c:\deps\bin\*intl*.dll

View File

@ -220,6 +220,7 @@ before_script:
- mkdir build && cd build
script:
- cmake -DCMAKE_INSTALL_PREFIX=$HOME/fluidsynth_install ${CMAKE_FLAGS} "-Denable-portaudio=1" "-Denable-ladspa=1" "-DCMAKE_BUILD_TYPE=RelWithDebInfo" ..
- cmake -DCMAKE_INSTALL_PREFIX=$HOME/fluidsynth_install ${CMAKE_FLAGS} "-Denable-portaudio=1" "-Denable-ladspa=1" "-DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_VERBOSE_MAKEFILE=1" ..
- make -j4
- if [ $TRAVIS_OS_NAME = linux ]; then make install; cmake -Denable-tests=1 ..; make check; fi # install only on linux, as CMAKE_INSTALL_PREFIX is ignored for frameworks on macosx and I cant tell whether that's correct or a bug. also build unit test only on linux, as libintl is not found on macosx
- make check
- if [ $TRAVIS_OS_NAME = linux ]; then make install; fi # install only on linux, as CMAKE_INSTALL_PREFIX is ignored for frameworks on macosx and I cant tell whether that's correct or a bug.

View File

@ -55,7 +55,6 @@ option ( enable-fpe-check "enable Floating Point Exception checks and debug mess
option ( enable-portaudio "compile PortAudio support" off )
option ( enable-profiling "profile the dsp code" off )
option ( enable-trap-on-fpe "enable SIGFPE trap on Floating Point Exceptions" off )
option ( enable-tests "build unit tests (implicitly disables BUILD_SHARED_LIBS)" off )
# Options enabled by default
option ( enable-aufile "compile support for sound file output" on )
@ -107,6 +106,11 @@ mark_as_advanced ( LIB_SUFFIX )
# the default C standard to use for all targets
set(CMAKE_C_STANDARD 90)
# Compile with position independent code if the user requested a shared lib, i.e. no PIC if static requested.
# This is cmakes default behavior, but here it's explicitly required due to the use of libfluidsynth-OBJ as object library,
# which would otherwise always be compiled without PIC.
set ( CMAKE_POSITION_INDEPENDENT_CODE ${BUILD_SHARED_LIBS} )
# the default global visibility level for all target
# no visibility support on OS2
if ( NOT OS2 )
@ -543,19 +547,11 @@ if ( OpenMP_FOUND OR OpenMP_C_FOUND )
endif()
endif()
# manipulate some variables to setup a proper test env
set(TEST_SOUNDFONT "${CMAKE_SOURCE_DIR}/sf2/VintageDreamsWaves-v2.sf2")
set(TEST_SOUNDFONT_SF3 "${CMAKE_SOURCE_DIR}/sf2/VintageDreamsWaves-v2.sf3")
if(enable-tests)
# manipulate some variables to setup a proper test env
set(TEST_SOUNDFONT "${CMAKE_SOURCE_DIR}/sf2/VintageDreamsWaves-v2.sf2")
set(TEST_SOUNDFONT_SF3 "${CMAKE_SOURCE_DIR}/sf2/VintageDreamsWaves-v2.sf3")
# force to build a static lib, in order to bypass the visibility control, allowing us
# to test fluidsynths private/internal functions
set(BUILD_SHARED_LIBS OFF)
add_subdirectory ( test )
endif(enable-tests)
add_subdirectory ( test )
# General configuration file
configure_file ( ${CMAKE_SOURCE_DIR}/src/config.cmake

View File

@ -1,5 +1,5 @@
macro ( ADD_FLUID_TEST _test )
ADD_EXECUTABLE(${_test} ${_test}.c)
ADD_EXECUTABLE(${_test} ${_test}.c $<TARGET_OBJECTS:libfluidsynth-OBJ> )
TARGET_LINK_LIBRARIES(${_test} libfluidsynth)
# use the local include path to look for fluidsynth.h, as we cannot be sure fluidsynth is already installed

View File

@ -247,10 +247,7 @@ link_directories (
${DBUS_LIBRARY_DIRS}
)
# note: by default this target creates a shared object (or dll). To build a
# static library instead, set the option BUILD_SHARED_LIBS to FALSE.
add_library ( libfluidsynth
add_library ( libfluidsynth-OBJ OBJECT
${config_SOURCES}
${fluid_alsa_SOURCES}
${fluid_coreaudio_SOURCES}
@ -270,6 +267,10 @@ add_library ( libfluidsynth
${VersionFilesOutputVariable}
)
# note: by default this target creates a shared object (or dll). To build a
# static library instead, set the option BUILD_SHARED_LIBS to FALSE.
add_library ( libfluidsynth $<TARGET_OBJECTS:libfluidsynth-OBJ> )
if ( MACOSX_FRAMEWORK )
set_property ( SOURCE ${public_HEADERS}
PROPERTY MACOSX_PACKAGE_LOCATION Headers/fluidsynth

View File

@ -16,6 +16,5 @@ To add a unit test just duplicate an existing one, give it a unique name and upd
* adding a call to `ADD_FLUID_TEST()` and
* a dependency to the custom `check` target.
Make sure you call cmake with `-Denable-tests=1` to build and execute the tests via `make check`. Unit
tests should use the `VintageDreamsWaves-v2.sf2` as test soundfont. Use the `TEST_SOUNDFONT` macro to
access it.
Execute the tests via `make check`. Unit tests should use the `VintageDreamsWaves-v2.sf2` as test soundfont.
Use the `TEST_SOUNDFONT` macro to access it.