cmake: simplifications
* All options reside in the top-level CMakeLists.txt file * No need to find gmio library, just add "gmio" as a target dependency * In tests, link to gmio library instead of recompiling needed source code
This commit is contained in:
parent
9fa87e8b20
commit
56bb6d8e65
@ -27,17 +27,20 @@ set(GMIO_VERSION_PATCH 0)
|
||||
set(GMIO_VERSION
|
||||
${GMIO_VERSION_MAJOR}.${GMIO_VERSION_MINOR}.${GMIO_VERSION_PATCH})
|
||||
|
||||
#set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
|
||||
# Options
|
||||
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)
|
||||
if(GMIO_BUILD_BENCHMARKS)
|
||||
option(GMIO_BUILD_BENCHMARK_ASSIMP "Build benchmark for Assimp" ON)
|
||||
option(GMIO_BUILD_BENCHMARK_OPENCASCADE "Build benchmark for OpenCascade" ON)
|
||||
endif()
|
||||
|
||||
# Detect Clang
|
||||
if (CMAKE_C_COMPILER MATCHES ".*clang")
|
||||
set(CMAKE_COMPILER_IS_CLANG 1)
|
||||
endif ()
|
||||
|
||||
# Options
|
||||
option(GMIO_BUILD_STRICT_C90 "Build gmio library(and tests) with strict conformance to C90 standard" OFF)
|
||||
option(GMIO_BUILD_BENCHMARKS "Build performance benchmarks for the gmio library" OFF)
|
||||
|
||||
# Find bit size of the target architecture
|
||||
math(EXPR GMIO_TARGET_ARCH_BIT_SIZE "8 * ${CMAKE_SIZEOF_VOID_P}")
|
||||
|
||||
@ -182,6 +185,8 @@ if(MSVC)
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /Oi")
|
||||
endif()
|
||||
|
||||
#set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
|
||||
|
||||
# Sub-directories
|
||||
add_subdirectory(src)
|
||||
add_subdirectory(tests)
|
||||
|
@ -13,10 +13,6 @@
|
||||
## "http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html".
|
||||
#############################################################################
|
||||
|
||||
# Options
|
||||
option(GMIO_BUILD_BENCHMARK_ASSIMP "Build benchmark for Assimp" ON)
|
||||
option(GMIO_BUILD_BENCHMARK_OPENCASCADE "Build benchmark for OpenCascade" ON)
|
||||
|
||||
set(ASSIMP_DIR ${CMAKE_SOURCE_DIR} CACHE PATH "Directory where the Assimp library resides")
|
||||
set(OPENCASCADE_DIR ${CMAKE_SOURCE_DIR} CACHE PATH "Directory where the OpenCascade library resides")
|
||||
|
||||
@ -26,14 +22,8 @@ set(COMMONS_FILES ${COMMONS_FILES})
|
||||
|
||||
include_directories(${CMAKE_SOURCE_DIR}/src)
|
||||
include_directories(${CMAKE_BINARY_DIR}/src/gmio_core) # For cmake generated headers
|
||||
link_directories(${CMAKE_BINARY_DIR}/src)
|
||||
find_library(GMIO_LIBPATH gmio HINTS ${CMAKE_BINARY_DIR}/src)
|
||||
get_filename_component(GMIO_LIB_BASENAME ${GMIO_LIBPATH} NAME_WE)
|
||||
if ("${GMIO_LIB_BASENAME}" STREQUAL "")
|
||||
set(GMIO_LIB_BASENAME "gmio")
|
||||
endif()
|
||||
link_libraries(${GMIO_LIB_BASENAME})
|
||||
if(CMAKE_COMPILER_IS_GNUCC)
|
||||
link_libraries(gmio)
|
||||
if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_CLANG)
|
||||
link_libraries(m) # -lm
|
||||
endif()
|
||||
|
||||
|
@ -13,10 +13,6 @@
|
||||
## "http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html".
|
||||
#############################################################################
|
||||
|
||||
# Options
|
||||
option(GMIO_BUILD_SHARED_LIBS "Build gmio as a shared library (DLL)" OFF)
|
||||
option(GMIO_BUILD_LIBSTL "Build also the libSTL module" ON)
|
||||
|
||||
# Add core source files
|
||||
file(GLOB GMIO_SRC_FILES gmio_core/* gmio_core/internal/*)
|
||||
set(GMIO_SRC_FILES ${GMIO_SRC_FILES})
|
||||
@ -43,16 +39,14 @@ file(GLOB GMIO_CORE_HEADERS gmio_core/*.h)
|
||||
install(FILES ${GMIO_CORE_HEADERS} DESTINATION include/gmio_core)
|
||||
|
||||
# Module libSTL
|
||||
if(GMIO_BUILD_LIBSTL)
|
||||
if(GMIO_BUILD_SHARED_LIBS)
|
||||
add_definitions(-DGMIO_LIBSTL_DLL
|
||||
-DGMIO_LIBSTL_MAKE_DLL)
|
||||
endif()
|
||||
|
||||
file(GLOB GMIO_LIBSTL_SRC_FILES gmio_stl/* gmio_stl/internal/*)
|
||||
set(GMIO_SRC_FILES ${GMIO_SRC_FILES} ${GMIO_LIBSTL_SRC_FILES})
|
||||
|
||||
if(GMIO_BUILD_SHARED_LIBS)
|
||||
add_definitions(-DGMIO_LIBSTL_DLL
|
||||
-DGMIO_LIBSTL_MAKE_DLL)
|
||||
endif()
|
||||
|
||||
file(GLOB GMIO_LIBSTL_SRC_FILES gmio_stl/* gmio_stl/internal/*)
|
||||
set(GMIO_SRC_FILES ${GMIO_SRC_FILES} ${GMIO_LIBSTL_SRC_FILES})
|
||||
|
||||
file(GLOB GMIO_LIBSTL_HEADERS gmio_stl/*.h)
|
||||
install(FILES ${GMIO_LIBSTL_HEADERS} DESTINATION include/gmio_stl)
|
||||
|
||||
|
@ -17,43 +17,37 @@ enable_testing()
|
||||
set(CMAKE_CTEST_COMMAND ctest -V)
|
||||
add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND})
|
||||
|
||||
include_directories(${CMAKE_BINARY_DIR}/src/gmio_core) # For generated header files
|
||||
include_directories(${CMAKE_BINARY_DIR}/src/gmio_core) # For generated cmake headers
|
||||
|
||||
# test_internal
|
||||
add_executable(
|
||||
test_internal
|
||||
EXCLUDE_FROM_ALL
|
||||
stream_buffer.c
|
||||
utils.c
|
||||
test_internal.c
|
||||
../src/gmio_core/stream.c
|
||||
../src/gmio_core/internal/string_parse.c)
|
||||
test_internal.c)
|
||||
target_link_libraries(test_internal gmio)
|
||||
|
||||
# test_platform
|
||||
add_executable(
|
||||
test_platform EXCLUDE_FROM_ALL test_platform.c)
|
||||
|
||||
# test_stl
|
||||
file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/models
|
||||
DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
|
||||
add_executable(
|
||||
test_stl
|
||||
EXCLUDE_FROM_ALL
|
||||
test_stl_io.c
|
||||
../src/gmio_core/buffer.c
|
||||
../src/gmio_core/stream.c
|
||||
../src/gmio_core/internal/string_parse.c
|
||||
../src/gmio_stl/stl_format.c
|
||||
../src/gmio_stl/stl_io.c
|
||||
../src/gmio_stl/stla_read.c
|
||||
../src/gmio_stl/stlb_read.c
|
||||
../src/gmio_stl/internal/stl_rw_common.c
|
||||
../src/gmio_stl/internal/stla_write.c
|
||||
../src/gmio_stl/internal/stlb_byte_swap.c
|
||||
../src/gmio_stl/internal/stlb_write.c)
|
||||
test_stl_io.c)
|
||||
target_link_libraries(test_stl gmio)
|
||||
|
||||
# GCC and Clang requires lm
|
||||
if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_CLANG)
|
||||
target_link_libraries(test_internal m) # -lm
|
||||
target_link_libraries(test_stl m) # -lm
|
||||
endif()
|
||||
|
||||
# Declare tests
|
||||
add_test(test_internal test_internal)
|
||||
add_test(test_platform test_platform)
|
||||
add_test(test_stl test_stl)
|
||||
|
Loading…
Reference in New Issue
Block a user