Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: Added options to compile with PIC and Flags for C++20 #115

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 19 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ option(RESTC_CPP_WITH_ZLIB "Use zlib" ON)

option(RESTC_CPP_USE_CPP17 "Use the C++17 standard" OFF)

option(RESTC_CPP_USE_CPP20 "Use the C++20 standard" OFF)

option(RESTC_CPP_PIC "Compile with -fPIC" OFF)

option(RESTC_CPP_THREADED_CTX "Allow asio contextx with multiple therads. Enables thread-safe internal access." OFF)

if (NOT DEFINED RESTC_CPP_MAX_INPUT_BUFFER_LENGTH)
Expand All @@ -78,12 +82,17 @@ endif()
message(STATUS "Using ${CMAKE_CXX_COMPILER}")

macro(SET_CPP_STANDARD target)
if (RESTC_CPP_USE_CPP17)
message(STATUS "Using C++ 17 for ${target}")
set_property(TARGET ${target} PROPERTY CXX_STANDARD 17)
if (RESTC_CPP_USE_CPP20)
message(STATUS "Using C++ 20 for ${target}")
set_property(TARGET ${target} PROPERTY CXX_STANDARD 20)
else()
message(STATUS "Using C++ 14 for ${target}")
set_property(TARGET ${target} PROPERTY CXX_STANDARD 14)
if (RESTC_CPP_USE_CPP17)
message(STATUS "Using C++ 17 for ${target}")
set_property(TARGET ${target} PROPERTY CXX_STANDARD 17)
else()
message(STATUS "Using C++ 14 for ${target}")
set_property(TARGET ${target} PROPERTY CXX_STANDARD 14)
endif()
endif()
endmacro(SET_CPP_STANDARD)

Expand Down Expand Up @@ -127,6 +136,11 @@ else()
endif()

add_library(${PROJECT_NAME} ${SOURCES})

if (DEFINED RESTC_CPP_PIC)
set_property(TARGET ${PROJECT_NAME} PROPERTY POSITION_INDEPENDENT_CODE ON)
endif()

set_target_properties(${PROJECT_NAME} PROPERTIES DEBUG_OUTPUT_NAME restc-cppD)
target_include_directories(${PROJECT_NAME}
PUBLIC
Expand Down