Commit 391f022b authored by Dominik Charousset's avatar Dominik Charousset

support build as static library

the configure script provides two new flags:
* `--build-static`
* `--build-static-only`
parent 556406fe
......@@ -174,25 +174,29 @@ if (DISABLE_CONTEXT_SWITCHING)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DCPPA_DISABLE_CONTEXT_SWITCHING")
endif ()
add_library(libcppa SHARED ${LIBCPPA_SRC})
set(LIBRARY_VERSION ${LIBCPPA_VERSION_MAJOR}.${LIBCPPA_VERSION_MINOR}.${LIBCPPA_VERSION_PATCH})
set(LIBRARY_SOVERSION ${LIBCPPA_VERSION_MAJOR})
set_target_properties(libcppa
PROPERTIES
SOVERSION ${LIBRARY_SOVERSION}
VERSION ${LIBRARY_VERSION}
OUTPUT_NAME cppa)
# bulid shared library only if not comiling static only
if (NOT "${CPPA_BUILD_STATIC_ONLY}" STREQUAL "yes")
add_library(libcppa SHARED ${LIBCPPA_SRC})
target_link_libraries(libcppa ${LD_FLAGS})
set(LIBRARY_VERSION ${LIBCPPA_VERSION_MAJOR}.${LIBCPPA_VERSION_MINOR}.${LIBCPPA_VERSION_PATCH})
set(LIBRARY_SOVERSION ${LIBCPPA_VERSION_MAJOR})
set_target_properties(libcppa
PROPERTIES
SOVERSION ${LIBRARY_SOVERSION}
VERSION ${LIBRARY_VERSION}
OUTPUT_NAME cppa)
install(TARGETS libcppa LIBRARY DESTINATION lib)
endif ()
add_library(libcppaStatic STATIC ${LIBCPPA_SRC})
set_target_properties(libcppaStatic PROPERTIES OUTPUT_NAME cppa)
# build static library if --build-static or --build-static-only was set
if ("${CPPA_BUILD_STATIC_ONLY}" STREQUAL "yes" OR "${CPPA_BUILD_STATIC}" STREQUAL "yes")
add_library(libcppaStatic STATIC ${LIBCPPA_SRC})
set_target_properties(libcppaStatic PROPERTIES OUTPUT_NAME cppa_static)
install(TARGETS libcppaStatic ARCHIVE DESTINATION lib)
endif ()
link_directories(${LD_DIRS})
include_directories(${INCLUDE_DIRS})
target_link_libraries(libcppa ${LD_FLAGS})
# install shared library
install(TARGETS libcppa LIBRARY DESTINATION lib)
# install includes
install(DIRECTORY cppa/ DESTINATION include/cppa FILES_MATCHING PATTERN "*.hpp")
......@@ -220,12 +224,16 @@ endif ()
set (CPPA_INCLUDE_PATH ${CMAKE_SOURCE_DIR}/libcppa)
set (CPPA_INCLUDE ${CPPA_INCLUDE_PATH})
if (APPLE)
set (CPPA_LIBRARY ${LIBRARY_OUTPUT_PATH}/libcppa.dylib)
elseif (UNIX)
set (CPPA_LIBRARY ${LIBRARY_OUTPUT_PATH}/libcppa.so)
if ("${CPPA_BUILD_STATIC_ONLY}" STREQUAL "yes")
set (CPPA_LIBRARY ${LIBRARY_OUTPUT_PATH}/libcppa_static.a ${LD_FLAGS})
else ()
message (SEND_FATAL "Host platform not supported ...")
if (APPLE)
set (CPPA_LIBRARY ${LIBRARY_OUTPUT_PATH}/libcppa.dylib)
elseif (UNIX)
set (CPPA_LIBRARY ${LIBRARY_OUTPUT_PATH}/libcppa.so)
else ()
message (SEND_FATAL "Host platform not supported ...")
endif ()
endif ()
if (EXECUTABLE_OUTPUT_PATH)
......@@ -235,13 +243,21 @@ endif ()
# set up subdirectories
if (NOT "${CPPA_NO_UNIT_TESTS}" STREQUAL "yes")
add_subdirectory(unit_testing)
add_dependencies(all_unit_tests libcppa)
enable_testing()
add_subdirectory(unit_testing)
if ("${CPPA_BUILD_STATIC_ONLY}" STREQUAL "yes")
add_dependencies(all_unit_tests libcppaStatic)
else ()
add_dependencies(all_unit_tests libcppa)
endif ()
endif ()
if (NOT "${CPPA_NO_EXAMPLES}" STREQUAL "yes")
add_subdirectory(examples)
add_dependencies(all_examples libcppa)
if ("${CPPA_BUILD_STATIC_ONLY}" STREQUAL "yes")
add_dependencies(all_examples libcppaStatic)
else ()
add_dependencies(all_examples libcppa)
endif ()
endif ()
# set optional flags
......@@ -262,6 +278,7 @@ if (DOXYGEN_FOUND)
VERBATIM)
endif (DOXYGEN_FOUND)
# set variables for summary
set(LOG_LEVEL_STR "none")
if (CPPA_LOG_LEVEL)
if (${CPPA_LOG_LEVEL} EQUAL 0)
......@@ -299,6 +316,16 @@ toYesNo(ENABLE_DEBUG DEBUG_MODE_STR)
invertYesNo(CPPA_NO_EXAMPLES BUILD_EXAMPLES)
invertYesNo(CPPA_NO_UNIT_TESTS BUILD_UNIT_TESTS)
if (NOT "${CPPA_BUILD_STATIC}" STREQUAL "yes")
set(CPPA_BUILD_STATIC "no")
endif ()
if (NOT "${CPPA_BUILD_STATIC_ONLY}" STREQUAL "yes")
set(CPPA_BUILD_STATIC_ONLY "no")
else ()
set(CPPA_BUILD_STATIC "yes")
endif ()
# done (print summary)
message("\n====================| Build Summary |===================="
"\n"
......@@ -310,6 +337,8 @@ message("\n====================| Build Summary |===================="
"\nContext switching: ${CONTEXT_SWITCHING}"
"\nBuild examples: ${BUILD_EXAMPLES}"
"\nBuild unit tests: ${BUILD_UNIT_TESTS}"
"\nBuild static: ${CPPA_BUILD_STATIC}"
"\nBulid static only: ${CPPA_BUILD_STATIC_ONLY}"
"\n"
"\nCXX: ${CMAKE_CXX_COMPILER}"
"\nCXXFLAGS: ${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_${build_type}}"
......
......@@ -31,6 +31,8 @@ Usage: $0 [OPTION]... [VAR=VALUE]...
--dual-build build both with gcc and clang
--no-examples build libcppa without examples
--no-unit-tests build libcppa without unit tests
--build-static build libcppa as static and shared library
--build-static-only build libcppa as static library only
Installation Directories:
--prefix=PREFIX installation directory [/usr/local]
......@@ -214,6 +216,12 @@ while [ $# -ne 0 ]; do
--no-unit-tests)
append_cache_entry CPPA_NO_UNIT_TESTS STRING yes
;;
--build-static)
append_cache_entry CPPA_BUILD_STATIC STRING yes
;;
--build-static-only)
append_cache_entry CPPA_BUILD_STATIC_ONLY STRING yes
;;
*)
echo "Invalid option '$1'. Try $0 --help to see available options."
exit 1
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment