-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
36 lines (29 loc) · 1 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
cmake_minimum_required(VERSION 3.24)
set(projName ithread)
project(${projName} C)
if("${CMAKE_CURRENT_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_BINARY_DIR}")
message(
FATAL_ERROR
"Building from within the libthread source tree is not supported.\n")
endif()
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release")
endif()
set(PROJECT_ROOT ${CMAKE_CURRENT_SOURCE_DIR})
include("${CMAKE_CURRENT_SOURCE_DIR}/cmake/utils.cmake")
defineinterfaces()
set(THREADS_PREFER_PTHREAD_FLAG TRUE)
find_package(Threads REQUIRED)
add_library(${projName} STATIC "${PROJECT_ROOT}/src/ithread.c")
target_link_libraries(
${projName}
PRIVATE "${projName}CompileOptions"
PRIVATE Threads::Threads)
target_include_directories(${projName} PUBLIC "${PROJECT_ROOT}/include/")
set_target_properties(
${projName} PROPERTIES PUBLIC_HEADER "${PROJECT_ROOT}/include/ithread.h")
include(GNUInstallDirs)
install(
TARGETS ${projName}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})