Skip to content

Commit e466556

Browse files
committed
Add CMake file for static linking
1 parent 504058c commit e466556

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

CMakeLists.txt

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
cmake_minimum_required(VERSION 3.15)
2+
3+
project(cloudflare-ddns)
4+
5+
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
6+
add_compile_options(-fuse-ld=lld -Wno-unused-command-line-argument)
7+
add_link_options(-fuse-ld=lld)
8+
endif()
9+
10+
include(CheckIPOSupported)
11+
check_ipo_supported(RESULT ipo_result OUTPUT ipo_output)
12+
if(ipo_result)
13+
cmake_policy(SET CMP0069 NEW)
14+
set(CMAKE_POLICY_DEFAULT_CMP0069 NEW)
15+
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE)
16+
endif()
17+
18+
include(FetchContent)
19+
20+
FetchContent_Declare(cpr GIT_REPOSITORY https://github.com/whoshuu/cpr.git GIT_TAG 1.5.2)
21+
set(BUILD_SHARED_LIBS OFF CACHE BOOL "")
22+
FetchContent_MakeAvailable(cpr)
23+
24+
FetchContent_Declare(json GIT_REPOSITORY https://github.com/ArthurSonzogni/nlohmann_json_cmake_fetchcontent.git GIT_TAG v3.9.1)
25+
FetchContent_GetProperties(json)
26+
if(NOT json_POPULATED)
27+
FetchContent_Populate(json)
28+
add_subdirectory(${json_SOURCE_DIR} ${json_BINARY_DIR} EXCLUDE_FROM_ALL)
29+
endif()
30+
31+
FetchContent_Declare(simdjson GIT_REPOSITORY https://github.com/simdjson/simdjson.git GIT_TAG v0.8.2 GIT_SHALLOW TRUE)
32+
set(SIMDJSON_JUST_LIBRARY ON CACHE INTERNAL "")
33+
set(SIMDJSON_BUILD_STATIC ON CACHE INTERNAL "")
34+
FetchContent_MakeAvailable(simdjson)
35+
36+
add_executable(${PROJECT_NAME} cloudflare-ddns/main.cpp)
37+
38+
target_link_libraries(${PROJECT_NAME} PRIVATE cpr::cpr nlohmann_json::nlohmann_json simdjson)

0 commit comments

Comments
 (0)