-
Notifications
You must be signed in to change notification settings - Fork 25
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
58 lines (44 loc) · 1.81 KB
/
CMakeLists.txt
File metadata and controls
58 lines (44 loc) · 1.81 KB
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
cmake_minimum_required(VERSION 3.10)
# Set the project name and version (adjust as needed).
project(grf VERSION 0.1.30 LANGUAGES C)
# Enable an option to choose between building a static or shared library.
option(BUILD_SHARED_LIB "Build as a shared library instead of static" ON)
option(BUILD_TESTS "Build the test executable" ON)
# Find ZLIB library - this makes ZLIB::ZLIB available.
find_package(ZLIB REQUIRED)
# List out all source files from the src directory.
set(SRC_FILES
"${CMAKE_CURRENT_SOURCE_DIR}/src/euc_kr.c"
"${CMAKE_CURRENT_SOURCE_DIR}/src/grf.c"
"${CMAKE_CURRENT_SOURCE_DIR}/src/hash_tables.c"
"${CMAKE_CURRENT_SOURCE_DIR}/src/main.c"
"${CMAKE_CURRENT_SOURCE_DIR}/src/zlib.c"
)
# Decide how the library will be built (STATIC or SHARED).
if(BUILD_SHARED_LIB)
add_library(grf SHARED ${SRC_FILES})
else()
add_library(grf STATIC ${SRC_FILES})
endif()
# Optionally set a C standard (e.g., C99).
# You can remove or update this to whatever standard you need.
set_property(TARGET grf PROPERTY C_STANDARD 99)
# Link against zlib.
target_link_libraries(grf PUBLIC ZLIB::ZLIB)
# If you have library headers you want other projects to use, specify them here:
target_include_directories(grf PUBLIC
"${CMAKE_CURRENT_SOURCE_DIR}/includes"
)
if(BUILD_TESTS)
# We use CMake's testing features.
include(CTest)
enable_testing()
# Create an executable from test.c
add_executable(grf_test "${CMAKE_CURRENT_SOURCE_DIR}/src/test.c")
# Link the test executable against our library
target_link_libraries(grf_test PRIVATE grf)
# Optionally, add a test to be run with "ctest" command
add_test(NAME run_grf_test COMMAND grf_test)
endif()
# If you have headers to install as well, list them here:
install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/includes/libgrf.h" DESTINATION include)