Skip to content

Commit

Permalink
refactor(examples): use function to add examples
Browse files Browse the repository at this point in the history
  • Loading branch information
Nerixyz authored and laudrup committed Mar 6, 2024
1 parent 2fd9ffc commit eebef41
Showing 1 changed file with 22 additions and 28 deletions.
50 changes: 22 additions & 28 deletions examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,32 +15,26 @@ if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
endif()

if(NOT ENABLE_WINTLS_STANDALONE_ASIO)
add_executable(https_client https_client.cpp)
add_executable(async_https_client async_https_client.cpp)

target_link_libraries(https_client PRIVATE
wintls
)

target_link_libraries(async_https_client PRIVATE
wintls
)

if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
# Temporary workaround issue https://github.com/boostorg/beast/issues/1582
target_compile_options(https_client PRIVATE "-wd4702")
target_compile_options(async_https_client PRIVATE "-wd4702")
endif()

if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
target_compile_options(https_client PRIVATE -Wno-unused-private-field)
target_compile_options(async_https_client PRIVATE -Wno-unused-private-field)
endif()

if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
# Work around string table overflow by enabling optimizations
target_compile_options(async_https_client PRIVATE -Os)
# Work around null pointer deref warning in boost code from GCC 12
target_compile_options(async_https_client PRIVATE -fno-delete-null-pointer-checks)
endif()
function(add_wintls_example name)
add_executable(${name} ${name}.cpp)
target_link_libraries(${name} PRIVATE wintls)
if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
# Temporary workaround issue https://github.com/boostorg/beast/issues/1582
target_compile_options(${name} PRIVATE "-wd4702")
endif()

if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
target_compile_options(${name} PRIVATE -Wno-unused-private-field)
endif()

if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
# Work around string table overflow by enabling optimizations
target_compile_options(${name} PRIVATE -Os)
# Work around null pointer deref warning in boost code from GCC 12
target_compile_options(${name} PRIVATE -fno-delete-null-pointer-checks)
endif()
endfunction()

add_wintls_example(https_client)
add_wintls_example(async_https_client)
endif()

0 comments on commit eebef41

Please sign in to comment.