2022-06-08 04:36:34 +08:00
|
|
|
cmake_minimum_required(VERSION 3.14)
|
|
|
|
|
2023-10-27 11:42:32 +08:00
|
|
|
project(gts VERSION "${VERSION}" LANGUAGES C)
|
2022-06-08 04:36:34 +08:00
|
|
|
|
|
|
|
find_package(PkgConfig REQUIRED)
|
|
|
|
pkg_check_modules(GLIB2 glib-2.0 IMPORTED_TARGET)
|
|
|
|
|
|
|
|
if(WIN32)
|
|
|
|
add_definitions(-DNATIVE_WIN32 -D_USE_MATH_DEFINES)
|
|
|
|
else()
|
2023-10-27 11:42:32 +08:00
|
|
|
include(CheckIncludeFile)
|
|
|
|
check_include_file("fpu_control.h" HAVE_FPU_CONTROL_H)
|
|
|
|
if(HAVE_FPU_CONTROL_H)
|
|
|
|
add_definitions(-DHAVE_FPU_CONTROL_H)
|
|
|
|
endif()
|
2022-06-08 04:36:34 +08:00
|
|
|
endif()
|
|
|
|
|
|
|
|
add_definitions(
|
|
|
|
-DGTS_COMPILATION
|
2023-10-27 11:42:32 +08:00
|
|
|
-DGTS_MAJOR_VERSION=${PROJECT_VERSION_MAJOR}
|
|
|
|
-DGTS_MINOR_VERSION=${PROJECT_VERSION_MINOR}
|
|
|
|
-DGTS_MICRO_VERSION=${PROJECT_VERSION_PATCH}
|
2022-06-08 04:36:34 +08:00
|
|
|
-DGTS_INTERFACE_AGE=1
|
|
|
|
-DGTS_BINARY_AGE=1
|
2023-10-27 11:42:32 +08:00
|
|
|
-DGTS_VERSION=${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}
|
2022-06-08 04:36:34 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
file(GLOB src src/*.c src/gts.def)
|
|
|
|
list(REMOVE_ITEM src src/predicate_init.c)
|
|
|
|
add_library(gts ${src})
|
|
|
|
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/config.h" "")
|
|
|
|
target_include_directories(gts PUBLIC
|
|
|
|
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src>
|
|
|
|
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>
|
|
|
|
$<INSTALL_INTERFACE:include>
|
|
|
|
)
|
|
|
|
target_link_libraries(gts PUBLIC PkgConfig::GLIB2)
|
|
|
|
|
|
|
|
set(prefix ?)
|
|
|
|
set(exec_prefix \${prefix})
|
|
|
|
set(libdir \${prefix}/lib)
|
|
|
|
set(includedir \${prefix}/include)
|
|
|
|
configure_file(gts.pc.in gts.pc @ONLY)
|
|
|
|
|
|
|
|
install(FILES src/gts.h src/gtsconfig.h DESTINATION include)
|
|
|
|
install(TARGETS gts)
|
|
|
|
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/gts.pc" DESTINATION lib/pkgconfig)
|