cmake: build static and DLL targets
This commit is contained in:
parent
fbf56aaa78
commit
091f665a6d
20
.travis.yml
20
.travis.yml
@ -13,32 +13,32 @@ _anchors:
|
|||||||
|
|
||||||
matrix:
|
matrix:
|
||||||
include:
|
include:
|
||||||
# Linux GCC-4.6 debug static coveralls
|
# Linux GCC-4.6 debug coveralls
|
||||||
- compiler: gcc
|
- compiler: gcc
|
||||||
env: TRAVIS_BUILD_TYPE=Debug TRAVIS_COVERALLS=ON
|
env: TRAVIS_BUILD_TYPE=Debug TRAVIS_COVERALLS=ON
|
||||||
# Linux GCC-4.6 debug static google_double-conversion
|
# Linux GCC-4.6 debug google_double-conversion
|
||||||
- compiler: gcc
|
- compiler: gcc
|
||||||
env: TRAVIS_BUILD_TYPE=Debug TRAVIS_FLOAT2STR_LIB=google_doubleconversion
|
env: TRAVIS_BUILD_TYPE=Debug TRAVIS_FLOAT2STR_LIB=google_doubleconversion
|
||||||
# Linux GCC-4.6 debug dll c90
|
# Linux GCC-4.6 debug no-dll c90
|
||||||
- compiler: gcc
|
- compiler: gcc
|
||||||
env: TRAVIS_BUILD_TYPE=Debug TRAVIS_SHARED_LIBS=ON TRAVIS_STRICT_C90=ON
|
env: TRAVIS_BUILD_TYPE=Debug TRAVIS_BUILD_DLL=OFF TRAVIS_STRICT_C90=ON
|
||||||
# Linux GCC-4.9 release static
|
# Linux GCC-4.9 release
|
||||||
- compiler: gcc-4.9
|
- compiler: gcc-4.9
|
||||||
addons: *gcc49-packages
|
addons: *gcc49-packages
|
||||||
env: TRAVIS_BUILD_TYPE=Release TRAVIS_GCC_VERSION=4.9
|
env: TRAVIS_BUILD_TYPE=Release TRAVIS_GCC_VERSION=4.9
|
||||||
# OSX Clang debug static
|
# OSX Clang debug
|
||||||
- os: osx
|
- os: osx
|
||||||
compiler: clang
|
compiler: clang
|
||||||
env: TRAVIS_BUILD_TYPE=Debug
|
env: TRAVIS_BUILD_TYPE=Debug
|
||||||
# OSX Clang debug static google_double-conversion
|
# OSX Clang debug google_double-conversion
|
||||||
- os: osx
|
- os: osx
|
||||||
compiler: clang
|
compiler: clang
|
||||||
env: TRAVIS_BUILD_TYPE=Debug TRAVIS_FLOAT2STR_LIB=google_doubleconversion
|
env: TRAVIS_BUILD_TYPE=Debug TRAVIS_FLOAT2STR_LIB=google_doubleconversion
|
||||||
# OSX Clang debug dll c90
|
# OSX Clang debug no-dll c90
|
||||||
- os: osx
|
- os: osx
|
||||||
compiler: clang
|
compiler: clang
|
||||||
env: TRAVIS_BUILD_TYPE=Debug TRAVIS_SHARED_LIBS=ON TRAVIS_STRICT_C90=ON
|
env: TRAVIS_BUILD_TYPE=Debug TRAVIS_BUILD_DLL=OFF TRAVIS_STRICT_C90=ON
|
||||||
# OSX Clang release static
|
# OSX Clang release
|
||||||
- os: osx
|
- os: osx
|
||||||
compiler: clang
|
compiler: clang
|
||||||
env: TRAVIS_BUILD_TYPE=Release
|
env: TRAVIS_BUILD_TYPE=Release
|
||||||
|
@ -67,8 +67,8 @@ else()
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Options
|
# Options
|
||||||
|
option(GMIO_BUILD_DLL "Build gmio also as a shared library(DLL)" ON)
|
||||||
option(GMIO_BUILD_STRICT_C90 "Build gmio library(and tests) with strict conformance to C90 standard" OFF)
|
option(GMIO_BUILD_STRICT_C90 "Build gmio library(and tests) with strict conformance to C90 standard" OFF)
|
||||||
option(GMIO_BUILD_SHARED_LIBS "Build gmio as a shared library (DLL)" OFF)
|
|
||||||
option(GMIO_BUILD_BENCHMARKS "Build performance benchmarks for the gmio library" OFF)
|
option(GMIO_BUILD_BENCHMARKS "Build performance benchmarks for the gmio library" OFF)
|
||||||
option(GMIO_BUILD_EXAMPLES "Build gmio examples" OFF)
|
option(GMIO_BUILD_EXAMPLES "Build gmio examples" OFF)
|
||||||
option(GMIO_BUILD_TESTS_FAKE_SUPPORT "Build tests/fake_support target" OFF)
|
option(GMIO_BUILD_TESTS_FAKE_SUPPORT "Build tests/fake_support target" OFF)
|
||||||
|
@ -14,11 +14,11 @@ clone_folder: c:\projects\gmio.git
|
|||||||
|
|
||||||
environment:
|
environment:
|
||||||
matrix:
|
matrix:
|
||||||
- APPVEYOR_SHARED_LIBS: OFF
|
- APPVEYOR_BUILD_DLL: ON
|
||||||
APPVEYOR_CMAKE_GENERATOR: "Visual Studio 12 2013"
|
APPVEYOR_CMAKE_GENERATOR: "Visual Studio 12 2013"
|
||||||
APPVEYOR_FLOAT2STR_LIB: std
|
APPVEYOR_FLOAT2STR_LIB: std
|
||||||
|
|
||||||
- APPVEYOR_SHARED_LIBS: ON
|
- APPVEYOR_BUILD_DLL: ON
|
||||||
APPVEYOR_CMAKE_GENERATOR: "Visual Studio 12 2013"
|
APPVEYOR_CMAKE_GENERATOR: "Visual Studio 12 2013"
|
||||||
APPVEYOR_FLOAT2STR_LIB: google_doubleconversion
|
APPVEYOR_FLOAT2STR_LIB: google_doubleconversion
|
||||||
|
|
||||||
@ -32,7 +32,7 @@ build_script:
|
|||||||
-G "%APPVEYOR_CMAKE_GENERATOR%" ^
|
-G "%APPVEYOR_CMAKE_GENERATOR%" ^
|
||||||
-DCMAKE_BUILD_TYPE=%CONFIGURATION% ^
|
-DCMAKE_BUILD_TYPE=%CONFIGURATION% ^
|
||||||
-DCMAKE_DEBUG_POSTFIX=_d ^
|
-DCMAKE_DEBUG_POSTFIX=_d ^
|
||||||
-DGMIO_BUILD_SHARED_LIBS=%APPVEYOR_SHARED_LIBS% ^
|
-DGMIO_BUILD_DLL=%APPVEYOR_BUILD_DLL% ^
|
||||||
-DGMIO_FLOAT2STR_LIB=%APPVEYOR_FLOAT2STR_LIB% ^
|
-DGMIO_FLOAT2STR_LIB=%APPVEYOR_FLOAT2STR_LIB% ^
|
||||||
-DGMIO_BUILD_EXAMPLES=ON ^
|
-DGMIO_BUILD_EXAMPLES=ON ^
|
||||||
-DGMIO_BUILD_BENCHMARKS=ON ^
|
-DGMIO_BUILD_BENCHMARKS=ON ^
|
||||||
|
@ -45,7 +45,7 @@ set(COMMONS_FILES ${COMMONS_FILES})
|
|||||||
include_directories(${CMAKE_SOURCE_DIR}/src)
|
include_directories(${CMAKE_SOURCE_DIR}/src)
|
||||||
include_directories(${CMAKE_BINARY_DIR}/src) # For cmake generated headers
|
include_directories(${CMAKE_BINARY_DIR}/src) # For cmake generated headers
|
||||||
include_directories(${CMAKE_BINARY_DIR}/src/gmio_core)
|
include_directories(${CMAKE_BINARY_DIR}/src/gmio_core)
|
||||||
link_libraries(gmio)
|
link_libraries(gmio_static)
|
||||||
if(CMAKE_C_COMPILER_IS_GCC_COMPATIBLE)
|
if(CMAKE_C_COMPILER_IS_GCC_COMPATIBLE)
|
||||||
link_libraries(m) # -lm
|
link_libraries(m) # -lm
|
||||||
endif()
|
endif()
|
||||||
|
@ -30,7 +30,7 @@
|
|||||||
include_directories(${CMAKE_SOURCE_DIR}/src)
|
include_directories(${CMAKE_SOURCE_DIR}/src)
|
||||||
include_directories(${CMAKE_BINARY_DIR}/src/gmio_core) # For cmake generated headers
|
include_directories(${CMAKE_BINARY_DIR}/src/gmio_core) # For cmake generated headers
|
||||||
include_directories(${CMAKE_SOURCE_DIR}/tests/fake_support/opencascade)
|
include_directories(${CMAKE_SOURCE_DIR}/tests/fake_support/opencascade)
|
||||||
link_libraries(gmio)
|
link_libraries(gmio_static)
|
||||||
if(CMAKE_C_COMPILER_IS_GCC_COMPATIBLE)
|
if(CMAKE_C_COMPILER_IS_GCC_COMPATIBLE)
|
||||||
link_libraries(m) # -lm
|
link_libraries(m) # -lm
|
||||||
endif()
|
endif()
|
||||||
|
@ -45,16 +45,6 @@ configure_file(gmio_core/version.h.cmake gmio_core/version.h @ONLY)
|
|||||||
configure_file(gmio_core/config.h.cmake gmio_core/config.h @ONLY)
|
configure_file(gmio_core/config.h.cmake gmio_core/config.h @ONLY)
|
||||||
include_directories(${CMAKE_BINARY_DIR}/src/gmio_core) # For cmake generated headers
|
include_directories(${CMAKE_BINARY_DIR}/src/gmio_core) # For cmake generated headers
|
||||||
|
|
||||||
# Enable DLL generation (export symbols)
|
|
||||||
if(GMIO_BUILD_SHARED_LIBS)
|
|
||||||
add_definitions(-DGMIO_DLL
|
|
||||||
-DGMIO_MAKING_DLL)
|
|
||||||
if(MSVC)
|
|
||||||
configure_file(gmio_core/gmio.rc.cmake gmio_core/gmio.rc @ONLY)
|
|
||||||
set(GMIO_SRC_FILES ${GMIO_SRC_FILES} ${CMAKE_BINARY_DIR}/src/gmio_core/gmio.rc)
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# Declare installs
|
# Declare installs
|
||||||
install(FILES ${CMAKE_BINARY_DIR}/src/gmio_core/version.h DESTINATION include/gmio_core)
|
install(FILES ${CMAKE_BINARY_DIR}/src/gmio_core/version.h DESTINATION include/gmio_core)
|
||||||
install(FILES ${CMAKE_BINARY_DIR}/src/gmio_core/config.h DESTINATION include/gmio_core)
|
install(FILES ${CMAKE_BINARY_DIR}/src/gmio_core/config.h DESTINATION include/gmio_core)
|
||||||
@ -63,11 +53,6 @@ file(GLOB GMIO_CORE_HEADERS gmio_core/*.h)
|
|||||||
install(FILES ${GMIO_CORE_HEADERS} DESTINATION include/gmio_core)
|
install(FILES ${GMIO_CORE_HEADERS} DESTINATION include/gmio_core)
|
||||||
|
|
||||||
# Module libSTL
|
# Module libSTL
|
||||||
#if(GMIO_BUILD_SHARED_LIBS)
|
|
||||||
# add_definitions(-DGMIO_STL_DLL
|
|
||||||
# -DGMIO_STL_MAKING_DLL)
|
|
||||||
#endif()
|
|
||||||
|
|
||||||
file(GLOB GMIO_LIBSTL_SRC_FILES gmio_stl/* gmio_stl/internal/*)
|
file(GLOB GMIO_LIBSTL_SRC_FILES gmio_stl/* gmio_stl/internal/*)
|
||||||
set(GMIO_SRC_FILES ${GMIO_SRC_FILES} ${GMIO_LIBSTL_SRC_FILES})
|
set(GMIO_SRC_FILES ${GMIO_SRC_FILES} ${GMIO_LIBSTL_SRC_FILES})
|
||||||
|
|
||||||
@ -83,30 +68,39 @@ install(FILES gmio_support/stream_qt.h DESTINATION include/gmio_support)
|
|||||||
install(FILES gmio_support/stream_qt.cpp DESTINATION src/gmio_support)
|
install(FILES gmio_support/stream_qt.cpp DESTINATION src/gmio_support)
|
||||||
|
|
||||||
# OpenCASCADE support
|
# OpenCASCADE support
|
||||||
install(FILES gmio_support/stl_occ_brep.h DESTINATION include/gmio_support)
|
install(FILES gmio_support/stl_occ_brep.h DESTINATION include/gmio_support)
|
||||||
install(FILES gmio_support/stl_occ_mesh.h DESTINATION include/gmio_support)
|
install(FILES gmio_support/stl_occ_mesh.h DESTINATION include/gmio_support)
|
||||||
install(FILES gmio_support/stl_occ_meshvs.h DESTINATION include/gmio_support)
|
install(FILES gmio_support/stl_occ_meshvs.h DESTINATION include/gmio_support)
|
||||||
install(FILES gmio_support/stl_occ_brep.cpp DESTINATION src/gmio_support)
|
install(FILES gmio_support/stl_occ_brep.cpp DESTINATION src/gmio_support)
|
||||||
install(FILES gmio_support/stl_occ_mesh.cpp DESTINATION src/gmio_support)
|
install(FILES gmio_support/stl_occ_mesh.cpp DESTINATION src/gmio_support)
|
||||||
install(FILES gmio_support/stl_occ_meshvs.cpp DESTINATION src/gmio_support)
|
install(FILES gmio_support/stl_occ_meshvs.cpp DESTINATION src/gmio_support)
|
||||||
install(FILES gmio_support/stl_occ_utils.h DESTINATION src/gmio_support)
|
install(FILES gmio_support/stl_occ_utils.h DESTINATION src/gmio_support)
|
||||||
|
|
||||||
# target
|
|
||||||
if(GMIO_BUILD_SHARED_LIBS)
|
|
||||||
add_library(gmio SHARED ${GMIO_SRC_FILES})
|
|
||||||
else()
|
|
||||||
add_library(gmio STATIC ${GMIO_SRC_FILES})
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# zlib
|
# zlib
|
||||||
if(GMIO_USE_BUNDLED_ZLIB)
|
if(GMIO_USE_BUNDLED_ZLIB)
|
||||||
add_subdirectory(3rdparty/zlib)
|
add_subdirectory(3rdparty/zlib)
|
||||||
endif()
|
endif()
|
||||||
include_directories(${ZLIB_INCLUDE_DIRS})
|
include_directories(${ZLIB_INCLUDE_DIRS})
|
||||||
target_link_libraries(gmio ${ZLIB_LIBRARIES})
|
|
||||||
|
# target
|
||||||
|
add_library(gmio_static STATIC ${GMIO_SRC_FILES})
|
||||||
|
target_link_libraries(gmio_static ${ZLIB_LIBRARIES})
|
||||||
|
if(GMIO_BUILD_DLL)
|
||||||
|
if(MSVC)
|
||||||
|
configure_file(gmio_core/gmio.rc.cmake gmio_core/gmio.rc @ONLY)
|
||||||
|
set(GMIO_SRC_FILES
|
||||||
|
${GMIO_SRC_FILES}
|
||||||
|
${CMAKE_BINARY_DIR}/src/gmio_core/gmio.rc)
|
||||||
|
endif()
|
||||||
|
add_library(gmio SHARED ${GMIO_SRC_FILES})
|
||||||
|
set_target_properties(
|
||||||
|
gmio PROPERTIES COMPILE_DEFINITIONS "GMIO_DLL;GMIO_MAKING_DLL")
|
||||||
|
target_link_libraries(gmio ${ZLIB_LIBRARIES})
|
||||||
|
set(GMIO_DLL_NAME gmio)
|
||||||
|
endif()
|
||||||
|
|
||||||
# Installs for target
|
# Installs for target
|
||||||
install(TARGETS gmio
|
install(TARGETS ${GMIO_DLL_NAME} gmio_static
|
||||||
RUNTIME DESTINATION lib
|
RUNTIME DESTINATION bin
|
||||||
LIBRARY DESTINATION lib
|
LIBRARY DESTINATION lib
|
||||||
ARCHIVE DESTINATION lib)
|
ARCHIVE DESTINATION lib)
|
||||||
|
@ -29,10 +29,6 @@
|
|||||||
|
|
||||||
enable_testing()
|
enable_testing()
|
||||||
set(CMAKE_CTEST_COMMAND ctest -V --timeout 120)
|
set(CMAKE_CTEST_COMMAND ctest -V --timeout 120)
|
||||||
if(WIN32 AND GMIO_BUILD_SHARED_LIBS)
|
|
||||||
configure_file(win_ctest_cmd.bat.cmake win_ctest_cmd.bat @ONLY)
|
|
||||||
set(CMAKE_CTEST_COMMAND win_ctest_cmd.bat)
|
|
||||||
endif()
|
|
||||||
add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND})
|
add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND})
|
||||||
|
|
||||||
include_directories(${CMAKE_BINARY_DIR}/src/gmio_core) # For generated cmake headers
|
include_directories(${CMAKE_BINARY_DIR}/src/gmio_core) # For generated cmake headers
|
||||||
@ -45,19 +41,9 @@ set(GMIO_TEST_CORE_SRC
|
|||||||
core_utils.c
|
core_utils.c
|
||||||
stream_buffer.c
|
stream_buffer.c
|
||||||
../benchmarks/commons/benchmark_tools.c)
|
../benchmarks/commons/benchmark_tools.c)
|
||||||
if(GMIO_BUILD_SHARED_LIBS)
|
|
||||||
# Note_1: MSVC wants it because internal symbols are not exported (GCC
|
|
||||||
# exports all symbols)
|
|
||||||
set(GMIO_TEST_CORE_SRC
|
|
||||||
${GMIO_TEST_CORE_SRC}
|
|
||||||
../src/gmio_core/internal/error_check.c
|
|
||||||
../src/gmio_core/internal/locale_utils.c
|
|
||||||
../src/gmio_core/internal/numeric_utils.c
|
|
||||||
../src/gmio_core/internal/stringstream.c)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
add_executable(test_core EXCLUDE_FROM_ALL ${GMIO_TEST_CORE_SRC})
|
add_executable(test_core EXCLUDE_FROM_ALL ${GMIO_TEST_CORE_SRC})
|
||||||
target_link_libraries(test_core gmio)
|
target_link_libraries(test_core gmio_static)
|
||||||
|
|
||||||
# test_stl
|
# test_stl
|
||||||
file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/models
|
file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/models
|
||||||
@ -67,17 +53,9 @@ set(GMIO_TEST_STL_SRC
|
|||||||
stl_testcases.c
|
stl_testcases.c
|
||||||
core_utils.c
|
core_utils.c
|
||||||
stl_utils.c)
|
stl_utils.c)
|
||||||
if(GMIO_BUILD_SHARED_LIBS)
|
|
||||||
# See Note_1
|
|
||||||
set(GMIO_TEST_STL_SRC
|
|
||||||
${GMIO_TEST_STL_SRC}
|
|
||||||
../src/gmio_core/internal/locale_utils.c
|
|
||||||
../src/gmio_core/internal/numeric_utils.c
|
|
||||||
../src/gmio_stl/internal/stl_error_check.c)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
add_executable(test_stl EXCLUDE_FROM_ALL ${GMIO_TEST_STL_SRC})
|
add_executable(test_stl EXCLUDE_FROM_ALL ${GMIO_TEST_STL_SRC})
|
||||||
target_link_libraries(test_stl gmio)
|
target_link_libraries(test_stl gmio_static)
|
||||||
|
|
||||||
# fake_support
|
# fake_support
|
||||||
if(GMIO_BUILD_TESTS_FAKE_SUPPORT)
|
if(GMIO_BUILD_TESTS_FAKE_SUPPORT)
|
||||||
|
@ -43,7 +43,7 @@ add_executable(
|
|||||||
../../src/gmio_support/stl_occ_meshvs.cpp
|
../../src/gmio_support/stl_occ_meshvs.cpp
|
||||||
../../src/gmio_support/stl_occ_brep.cpp
|
../../src/gmio_support/stl_occ_brep.cpp
|
||||||
../../src/gmio_support/stream_qt.cpp)
|
../../src/gmio_support/stream_qt.cpp)
|
||||||
target_link_libraries(fake_support gmio)
|
target_link_libraries(fake_support gmio_static)
|
||||||
include_directories(
|
include_directories(
|
||||||
${CMAKE_SOURCE_DIR}/src
|
${CMAKE_SOURCE_DIR}/src
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/opencascade
|
${CMAKE_CURRENT_SOURCE_DIR}/opencascade
|
||||||
|
@ -54,7 +54,7 @@ static const char* test_core__buffer()
|
|||||||
UTEST_ASSERT(buff.ptr != NULL);
|
UTEST_ASSERT(buff.ptr != NULL);
|
||||||
UTEST_ASSERT(buff.size == buff_size);
|
UTEST_ASSERT(buff.size == buff_size);
|
||||||
UTEST_ASSERT(memcmp(buff.ptr, &zero_buff[0], buff_size) == 0);
|
UTEST_ASSERT(memcmp(buff.ptr, &zero_buff[0], buff_size) == 0);
|
||||||
/* TODO: make assert succeed with mingw and GMIO_BUILD_SHARED_LIBS=ON
|
/* TODO: make assert succeed with mingw and gmio as a DLL
|
||||||
* In this case free() has not the same address in libgmio.dll and
|
* In this case free() has not the same address in libgmio.dll and
|
||||||
* test_core.exe */
|
* test_core.exe */
|
||||||
UTEST_ASSERT(buff.func_deallocate == &free);
|
UTEST_ASSERT(buff.func_deallocate == &free);
|
||||||
|
@ -21,8 +21,8 @@ if [ -n "${TRAVIS_GCC_VERSION}" ]; then
|
|||||||
export CXX=g++-$TRAVIS_GCC_VERSION;
|
export CXX=g++-$TRAVIS_GCC_VERSION;
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -z "${TRAVIS_SHARED_LIBS}" ]; then
|
if [ -z "${TRAVIS_BUILD_DLL}" ]; then
|
||||||
export TRAVIS_SHARED_LIBS=OFF;
|
export TRAVIS_BUILD_DLL=OFF;
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -z "${TRAVIS_STRICT_C90}" ]; then
|
if [ -z "${TRAVIS_STRICT_C90}" ]; then
|
||||||
@ -41,7 +41,7 @@ cmake .. -G "Unix Makefiles" \
|
|||||||
-DCMAKE_DEBUG_POSTFIX=_d \
|
-DCMAKE_DEBUG_POSTFIX=_d \
|
||||||
-DCMAKE_BUILD_TYPE=$TRAVIS_BUILD_TYPE \
|
-DCMAKE_BUILD_TYPE=$TRAVIS_BUILD_TYPE \
|
||||||
-DCMAKE_INSTALL_PREFIX=../install \
|
-DCMAKE_INSTALL_PREFIX=../install \
|
||||||
-DGMIO_BUILD_SHARED_LIBS=$TRAVIS_SHARED_LIBS \
|
-DGMIO_BUILD_DLL=$TRAVIS_BUILD_DLL \
|
||||||
-DGMIO_BUILD_STRICT_C90=$TRAVIS_STRICT_C90 \
|
-DGMIO_BUILD_STRICT_C90=$TRAVIS_STRICT_C90 \
|
||||||
-DGMIO_BUILD_EXAMPLES=ON \
|
-DGMIO_BUILD_EXAMPLES=ON \
|
||||||
-DGMIO_BUILD_BENCHMARKS=ON \
|
-DGMIO_BUILD_BENCHMARKS=ON \
|
||||||
|
Loading…
Reference in New Issue
Block a user