This repository has been archived on 2026-04-17. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
bhlib-old/CMakeLists.txt

110 lines
2.3 KiB
CMake
Raw Normal View History

2024-04-13 14:52:29 +03:00
cmake_minimum_required(VERSION 3.10)
# Project and C standard configuration
project(bhlib LANGUAGES C)
set(CMAKE_C_STANDARD 90)
set(CMAKE_C_STANDARD_REQUIRED ON)
2024-04-14 22:32:58 +03:00
# Project includes
2024-04-13 14:52:29 +03:00
include(CheckIPOSupported)
2024-04-14 22:32:58 +03:00
include(CheckIncludeFile)
include(CheckSymbolExists)
# Check for IPO/LTO
2024-04-13 14:52:29 +03:00
check_ipo_supported(RESULT supported)
if(supported)
message(STATUS "IPO/LTO enabled")
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE)
endif()
# Enable testing
include(CTest)
enable_testing()
# Set library code
set(BHLIB_SOURCE
src/algo.c
2024-04-13 14:52:29 +03:00
src/hashmap.c
src/queue.c
2024-04-14 22:32:58 +03:00
src/thread.c
src/io.c
src/deflate.c
2024-04-13 14:52:29 +03:00
)
set(BHLIB_HEADER
include/bh/bh.h
include/bh/platform.h
include/bh/algo.h
2024-04-13 14:52:29 +03:00
include/bh/hashmap.h
include/bh/queue.h
include/bh/thread.h
include/bh/io.h
include/bh/deflate.h
2024-04-13 14:52:29 +03:00
)
2024-04-14 22:32:58 +03:00
set(BHLIB_INCLUDE_DIRS
include
${PROJECT_BINARY_DIR}/include
)
# Determine platform
if(WIN32)
message(STATUS "Platform - Win32")
# Check multithreading support
check_symbol_exists(_beginthread process.h BHLIB_USE_WINTHREAD)
if(BHLIB_USE_WINTHREAD)
message(STATUS "Multithreading enabled")
list(APPEND BHLIB_SOURCE
src/thread_win.c
)
else()
message(STATUS "Multithreading disabled")
list(APPEND BHLIB_SOURCE
src/thread_null.c
)
endif()
elseif(UNIX)
message(STATUS "Platform: Unix (Linux/BSD/MacOS X)")
# Check multithreading support
check_include_file(pthread.h BHLIB_USE_PTHREAD)
if(BHLIB_USE_PTHREAD)
message(STATUS "Multithreading enabled")
list(APPEND BHLIB_SOURCE
src/thread_posix.c
)
else()
message(STATUS "Multithreading disabled")
list(APPEND BHLIB_SOURCE
src/thread_null.c
)
endif()
else()
message(STATUS "Platform: Unknown")
message(STATUS "Multithreading disabled")
list(APPEND BHLIB_SOURCE
src/thread_null.c
)
endif()
# Configure library
configure_file(include/bh/config.in include/bh/config.h)
2024-04-13 14:52:29 +03:00
# Library
add_library(bhlib STATIC ${BHLIB_SOURCE} ${BHLIB_HEADER})
2024-04-14 22:32:58 +03:00
target_include_directories(bhlib PUBLIC ${BHLIB_INCLUDE_DIRS})
2024-04-13 14:52:29 +03:00
# Runtime definition
add_executable(main
main.c
)
target_link_libraries(main bhlib)
# Tests
add_subdirectory(unit)
add_subdirectory(tests)