Enable optional static library for standalone build

Fixes #89
This commit is contained in:
Dmitry Marakasov 2017-04-21 14:37:54 +03:00
parent 82f24a8c93
commit f917113c34
3 changed files with 20 additions and 7 deletions

View File

@ -12,6 +12,8 @@ matrix:
env: CXXSTD=c++11
- compiler: clang
env: CXXSTD=c++1y BUILD_NOOPTLIBS=yes
- compiler: clang
env: CXXSTD=c++1y BUILD_STATIC=yes
before_install:
- sudo apt-get update -qq
- sudo apt-get install -qq cmake libsdl2-dev cppcheck doxygen pulseaudio
@ -26,6 +28,9 @@ before_install:
else
sudo apt-get install -qq libsdl2-image-dev libsdl2-ttf-dev libsdl2-mixer-dev
fi
if [ -n "${BUILD_STATIC}" ]; then
export CMAKE_EXTRA_ARGS="${CMAKE_EXTRA_ARGS} -DSDL2PP_STATIC=YES"
fi
# evironment for live tests
- dbus-launch pulseaudio --start

View File

@ -208,19 +208,26 @@ ENDIF(SDL2PP_WITH_MIXER)
INCLUDE(GenerateExportHeader)
IF(CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR)
# options
OPTION(SDL2PP_WITH_EXAMPLES "Build examples" ON)
OPTION(SDL2PP_WITH_TESTS "Build tests" ON)
OPTION(SDL2PP_ENABLE_LIVE_TESTS "Enable live tests (require X11 display and audio device)" ON)
OPTION(SDL2PP_STATIC "Build static library instead of shared one" OFF)
# library
ADD_LIBRARY(SDL2pp SHARED ${LIBRARY_SOURCES} ${LIBRARY_HEADERS})
IF(SDL2PP_STATIC)
ADD_LIBRARY(SDL2pp STATIC ${LIBRARY_SOURCES} ${LIBRARY_HEADERS})
ELSE(SDL2PP_STATIC)
ADD_LIBRARY(SDL2pp SHARED ${LIBRARY_SOURCES} ${LIBRARY_HEADERS})
TARGET_LINK_LIBRARIES(SDL2pp ${SDL2_ALL_LIBRARIES})
SET_TARGET_PROPERTIES(SDL2pp PROPERTIES VERSION 8.0.0 SOVERSION 8)
ENDIF(SDL2PP_SHARED)
GENERATE_EXPORT_HEADER(SDL2pp EXPORT_FILE_NAME SDL2pp/Export.hh)
TARGET_LINK_LIBRARIES(SDL2pp ${SDL2_ALL_LIBRARIES})
SET_TARGET_PROPERTIES(SDL2pp PROPERTIES VERSION 8.0.0 SOVERSION 8)
SET(SDL2PP_LIBRARIES ${SDL2PP_EXTRA_LIBRARIES} SDL2pp ${SDL2_ALL_LIBRARIES})
# examples and tests
OPTION(SDL2PP_WITH_EXAMPLES "Build examples" ON)
OPTION(SDL2PP_WITH_TESTS "Build tests" ON)
OPTION(SDL2PP_ENABLE_LIVE_TESTS "Enable live tests (require X11 display and audio device)" ON)
IF(SDL2PP_WITH_EXAMPLES)
ADD_SUBDIRECTORY(examples)
ENDIF(SDL2PP_WITH_EXAMPLES)

View File

@ -160,6 +160,7 @@ Following variables may be supplied to CMake to affect build:
* ```SDL2PP_CXXSTD``` - override C++ standard (default C++11). With C++1y some additional features are enabled such as usage of [[deprecated]] attribute and using stock experimental/optional from C++ standard library
* ```SDL2PP_WITH_EXAMPLES``` - enable building example programs (only for standalone build, default ON)
* ```SDL2PP_WITH_TESTS``` - enable building tests (only for standalone build, default ON)
* ```SDL2PP_STATIC``` - build static library instead of shared (only for standalone build, default OFF)
* ```SDL2PP_ENABLE_LIVE_TESTS``` - enable tests which require X11 and/or audio device to run (only for standalone build, default ON)
## Installation ##