mirror of
https://github.com/TREX-CoE/trexio.git
synced 2025-01-03 18:16:22 +01:00
[CMake] add minor support for pthreads and stdint
This commit is contained in:
parent
5db1de3d3c
commit
2a9cfb3fa4
@ -49,7 +49,8 @@ if(EXISTS "${CMAKE_SOURCE_DIR}/.git/config")
|
|||||||
# replace placeholders in the templace config.h.in file to produce config.h
|
# replace placeholders in the templace config.h.in file to produce config.h
|
||||||
# config.h is needed to insert TREXIO_PACKAGE_VERSION and TREXIO_GIT_HASH into trexio.h
|
# config.h is needed to insert TREXIO_PACKAGE_VERSION and TREXIO_GIT_HASH into trexio.h
|
||||||
configure_file(${CMAKE_SOURCE_DIR}/include/cmake_config.h.in
|
configure_file(${CMAKE_SOURCE_DIR}/include/cmake_config.h.in
|
||||||
${CMAKE_SOURCE_DIR}/include/config.h)
|
${CMAKE_SOURCE_DIR}/include/config.h
|
||||||
|
@ONLY)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Set directories to be included at build time.
|
# Set directories to be included at build time.
|
||||||
|
@ -1,13 +1,26 @@
|
|||||||
|
|
||||||
# ========= DEFINE TREXIO C LIBRARY =========
|
# ============= THREADS SUPPORT ==============
|
||||||
|
|
||||||
|
# the two options below add preference for the pthread library over other system-wide threads implementations
|
||||||
|
set(CMAKE_THREAD_PREFER_PTHREAD TRUE)
|
||||||
|
set(THREADS_PREFER_PTHREAD_FLAG TRUE)
|
||||||
|
# find thread library
|
||||||
|
find_package(Threads REQUIRED)
|
||||||
|
|
||||||
|
# ============= STDINT SUPPORT ===============
|
||||||
|
|
||||||
|
include(CheckIncludeFile)
|
||||||
|
check_include_file(stdint.h HAVE_STDINT_H)
|
||||||
|
|
||||||
|
# ========= DEFINE TREXIO C LIBRARY =========
|
||||||
|
|
||||||
# Set a list of TREXIO source and header files that are always compiled.
|
# Set a list of TREXIO source and header files that are always compiled.
|
||||||
set(TREXIO_SOURCES
|
set(TREXIO_SOURCES
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/trexio.c
|
${CMAKE_CURRENT_SOURCE_DIR}/trexio.c
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/trexio_text.c
|
${CMAKE_CURRENT_SOURCE_DIR}/trexio_text.c
|
||||||
)
|
)
|
||||||
set(TREXIO_PUBLIC_HEADERS ${CMAKE_SOURCE_DIR}/include/trexio.h)
|
set(TREXIO_PUBLIC_HEADERS ${CMAKE_SOURCE_DIR}/include/trexio.h)
|
||||||
set(TREXIO_PRIVATE_HEADERS
|
set(TREXIO_PRIVATE_HEADERS
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/trexio_s.h
|
${CMAKE_CURRENT_SOURCE_DIR}/trexio_s.h
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/trexio_private.h
|
${CMAKE_CURRENT_SOURCE_DIR}/trexio_private.h
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/trexio_text.h
|
${CMAKE_CURRENT_SOURCE_DIR}/trexio_text.h
|
||||||
@ -29,7 +42,7 @@ if(BUILD_SHARED_LIBS AND NOT BUILD_STATIC_LIBS)
|
|||||||
add_library(trexio SHARED)
|
add_library(trexio SHARED)
|
||||||
|
|
||||||
elseif(NOT BUILD_SHARED_LIBS AND BUILD_STATIC_LIBS)
|
elseif(NOT BUILD_SHARED_LIBS AND BUILD_STATIC_LIBS)
|
||||||
|
|
||||||
message(STATUS "TREXIO :: static C library will be built")
|
message(STATUS "TREXIO :: static C library will be built")
|
||||||
add_library(trexio STATIC)
|
add_library(trexio STATIC)
|
||||||
# Static TREXIO has to be compiled with -fPIC flag. For Shared it is done by default.
|
# Static TREXIO has to be compiled with -fPIC flag. For Shared it is done by default.
|
||||||
@ -40,12 +53,12 @@ else()
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Set TREXIO version and include files.
|
# Set TREXIO version and include files.
|
||||||
set_target_properties(trexio PROPERTIES
|
set_target_properties(trexio PROPERTIES
|
||||||
VERSION ${PROJECT_VERSION}
|
VERSION ${PROJECT_VERSION}
|
||||||
PUBLIC_HEADER ${TREXIO_PUBLIC_HEADERS}
|
PUBLIC_HEADER ${TREXIO_PUBLIC_HEADERS}
|
||||||
)
|
)
|
||||||
|
|
||||||
# ============= CONFIGURE HDF5 ==============
|
# ============= CONFIGURE HDF5 ==============
|
||||||
|
|
||||||
# By defaulti, TREXIO is configured with the HDF5 support.
|
# By defaulti, TREXIO is configured with the HDF5 support.
|
||||||
# To change this, append -DENABLE_HDF5=OFF to the cmake call.
|
# To change this, append -DENABLE_HDF5=OFF to the cmake call.
|
||||||
@ -74,8 +87,8 @@ if(ENABLE_HDF5)
|
|||||||
# - include directories with HDF5 header files
|
# - include directories with HDF5 header files
|
||||||
target_include_directories(trexio PRIVATE ${HDF5_C_INCLUDE_DIRS})
|
target_include_directories(trexio PRIVATE ${HDF5_C_INCLUDE_DIRS})
|
||||||
# - link to HDF5 C libraries
|
# - link to HDF5 C libraries
|
||||||
target_link_libraries(trexio PRIVATE
|
target_link_libraries(trexio PRIVATE
|
||||||
${HDF5_C_HL_LIBRARIES}
|
${HDF5_C_HL_LIBRARIES}
|
||||||
${HDF5_C_LIBRARIES})
|
${HDF5_C_LIBRARIES})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
@ -110,7 +123,7 @@ if(TREXIO_DEVEL)
|
|||||||
list(APPEND ORG_FILES templates_hdf5/templator_hdf5.org)
|
list(APPEND ORG_FILES templates_hdf5/templator_hdf5.org)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
add_custom_command(OUTPUT
|
add_custom_command(OUTPUT
|
||||||
${TREXIO_SOURCES}
|
${TREXIO_SOURCES}
|
||||||
${TREXIO_PUBLIC_HEADERS}
|
${TREXIO_PUBLIC_HEADERS}
|
||||||
${TREXIO_PRIVATE_HEADERS}
|
${TREXIO_PRIVATE_HEADERS}
|
||||||
@ -129,7 +142,7 @@ if(TREXIO_DEVEL)
|
|||||||
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# ============= INSTALL TREXIO ==============
|
# ============= INSTALL TREXIO ==============
|
||||||
|
|
||||||
include(GNUInstallDirs)
|
include(GNUInstallDirs)
|
||||||
# Use standard GNU directories for installation of TREXIO (e.g. /usr/local/lib|include).
|
# Use standard GNU directories for installation of TREXIO (e.g. /usr/local/lib|include).
|
||||||
@ -153,4 +166,4 @@ if(NOT TARGET uninstall)
|
|||||||
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake)
|
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# ===========================================
|
# ===========================================
|
||||||
|
Loading…
Reference in New Issue
Block a user