Skip to content

Commit 5ac75e6

Browse files
committed
add cmakelists back in
1 parent 2512685 commit 5ac75e6

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

CMakeLists.txt

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# SPDX-FileCopyrightText: 2024 Binsparse Developers
2+
#
3+
# SPDX-License-Identifier: BSD-3-Clause
4+
5+
cmake_minimum_required(VERSION 3.5)
6+
project(binsparse-rc)
7+
8+
cmake_policy(SET CMP0079 NEW)
9+
10+
set(CMAKE_C_STANDARD 11)
11+
12+
set(CMAKE_CXX_STANDARD 20)
13+
14+
set(CMAKE_C_FLAGS "-O3 -march=native")
15+
16+
add_library(binsparse-rc SHARED)
17+
18+
add_subdirectory(include)
19+
add_subdirectory(src)
20+
21+
# NOTE: For now, both HDF5 and cJSON are `PUBLIC`, meaning that anything that
22+
# depends on `binsparse-rc` will also link/include HDF5 and cJSON. We can change
23+
# these to `PRIVATE` to use them only when building binsparse-rc.
24+
25+
find_package(HDF5 REQUIRED COMPONENTS C)
26+
target_link_libraries(binsparse-rc PUBLIC ${HDF5_C_LIBRARIES})
27+
target_include_directories(binsparse-rc PUBLIC . ${HDF5_INCLUDE_DIRS})
28+
29+
include(FetchContent)
30+
FetchContent_Declare(
31+
cJSON
32+
GIT_REPOSITORY https://github.com/DaveGamble/cJSON.git
33+
GIT_TAG v1.7.17
34+
)
35+
FetchContent_MakeAvailable(cJSON)
36+
37+
configure_file(${cJSON_SOURCE_DIR}/cJSON.h ${CMAKE_BINARY_DIR}/include/cJSON/cJSON.h)
38+
target_include_directories(${PROJECT_NAME} PUBLIC ${CMAKE_BINARY_DIR}/include)
39+
target_link_libraries(${PROJECT_NAME} PUBLIC cjson)
40+
41+
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
42+
add_subdirectory(examples)
43+
add_subdirectory(test)
44+
endif()

0 commit comments

Comments
 (0)