-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
81 lines (60 loc) · 2.31 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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
cmake_minimum_required(VERSION 3.28)
project(function-test)
set(CMAKE_CXX_STANDARD 20)
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wformat=2 -Wconversion -Wimplicit-fallthrough")
#elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
endif()
include(FetchContent)
# Setup Asio
# Based on cmake file provided by havogt:
# https://stackoverflow.com/questions/65586352/is-it-possible-to-use-fetchcontent-or-an-equivalent-to-add-a-library-that-has-no
set(CROW_USE_BOOST 0)
set(CROW_AMALGAMATE 0)
set(CROW_BUILD_TESTS 0)
FetchContent_Declare(crow
GIT_REPOSITORY https://github.com/CrowCpp/Crow.git
GIT_TAG master
CONFIGURE_COMMAND ""
BUILD_COMMAND ""
)
FetchContent_GetProperties(crow)
if(NOT crow_POPULATED)
FetchContent_MakeAvailable(crow)
endif()
# We use Crow's cmake module to find the asio installed on the local system,
# this is because Crow does not seem to play nicely with an asio from fetch_content
list(APPEND CMAKE_MODULE_PATH ${crow_SOURCE_DIR}/cmake)
find_package(asio REQUIRED)
add_library(crow INTERFACE)
target_include_directories(crow INTERFACE ${crow_SOURCE_DIR}/include)
target_link_libraries(crow INTERFACE asio::asio Threads::Threads)
# Own application
add_executable(function-test
src/main.cpp
src/main.cpp
src/host_types.hpp)
target_compile_definitions(function-test INTERFACE USE_STANDALONE_ASIO)
#target_compile_definitions(function-test INTERFACE ASIO_NO_TS_EXECUTORS)
#target_include_directories(function-test PRIVATE )
target_link_libraries(function-test PRIVATE asio::asio crow)
add_custom_command(
TARGET function-test POST_BUILD
COMMAND cp
${CMAKE_SOURCE_DIR}/local.settings.json
${CMAKE_CURRENT_BINARY_DIR}/local.settings.json)
add_custom_command(
TARGET function-test POST_BUILD
COMMAND cp
${CMAKE_SOURCE_DIR}/host.json
${CMAKE_CURRENT_BINARY_DIR}/host.json)
add_custom_command(
TARGET function-test POST_BUILD
COMMAND cp -r
${CMAKE_SOURCE_DIR}/simple-http-trigger
${CMAKE_CURRENT_BINARY_DIR})
add_custom_command(
TARGET function-test POST_BUILD
COMMAND cp -r
${CMAKE_SOURCE_DIR}/queue-trigger
${CMAKE_CURRENT_BINARY_DIR})