generated from joshuadahlunr/go-cmake
-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
executable file
·40 lines (30 loc) · 1.32 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
37
38
39
40
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
cmake_minimum_required(VERSION 3.21)
option(BUILD_EXAMPLES "Build the example applications" ${PROJECT_IS_TOP_LEVEL})
project(simplep2p Go CXX C)
include(cmake/golang.cmake)
include(cmake/flags.cmake)
# If we are compiling on windows overwrite the GOROOT based on the compiler path
if(WIN32)
cmake_path(REMOVE_FILENAME CMAKE_Go_COMPILER OUTPUT_VARIABLE GOROOT)
cmake_path(APPEND GOROOT "../lib/go")
cmake_path(ABSOLUTE_PATH GOROOT NORMALIZE)
message("Overwriting GOROOT with ${GOROOT}")
endif()
add_go_library_with_modules(simplep2p_golib STATIC src/libp2p.go)
target_go_get_dependency(simplep2p_golib NAME get_libp2p PACKAGES github.com/libp2p/go-libp2p)
add_library(simplep2p STATIC src/simplep2p.c)
target_include_directories(simplep2p PUBLIC src)
target_link_libraries(simplep2p PRIVATE simplep2p_golib)
if(BUILD_EXAMPLES)
add_subdirectory(examples/argparse)
add_executable(chat examples/chat.cpp)
target_link_libraries(chat simplep2p argparse)
set_property(TARGET chat PROPERTY CXX_STANDARD 20)
add_executable(chat.capi examples/chat.capi.cpp)
target_link_libraries(chat.capi simplep2p argparse)
set_property(TARGET chat.capi PROPERTY CXX_STANDARD 20)
if(MSVC)
target_link_libraries(chat.capi legacy_stdio_definitions.lib)
endif()
endif()