Skip to content

Commit

Permalink
cmake compiler opts and lib dependency fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
milyin committed Aug 31, 2023
1 parent 66a8fdd commit b84fb34
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,20 @@ if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_definitions(${ZENOH_DEBUG_OPT} -DZENOH_DEBUG=1)
endif()

set(release_opts -pipe -O3)
set(debug_opts -Wall -Wextra -Werror -Wpedantic -Wunused -Wstrict-prototypes -pipe -g -O0)
add_compile_options(
$<$<CONFIG:RELEASE>:-pipe -O3>
$<$<CONFIG:DEBUG>:-Wall -Wextra -Werror -Wpedantic -Wunused -Wstrict-prototypes -pipe -g -O0>
"$<$<CONFIG:RELEASE>:${release_opts}>"
"$<$<CONFIG:DEBUG>:${debug_opts}>"
)
endif()

set(Libname "zenohpico")
if(BUILD_SHARED_LIBS)
add_library(${Libname} SHARED)
else()
add_library(${Libname} STATIC)
endif()

file(GLOB PublicHeaders "include/*.h"
"include/zenoh-pico/*.h"
Expand All @@ -108,9 +115,7 @@ file(GLOB PublicHeaders "include/*.h"
"include/zenoh-pico/transport/*.h"
"include/zenoh-pico/utils/*.h"
)
include_directories(
${PROJECT_SOURCE_DIR}/include
)
target_include_directories(${Libname} PUBLIC ${PROJECT_SOURCE_DIR}/include)

if (UNIX)
file(GLOB Sources "src/*.c"
Expand Down Expand Up @@ -138,7 +143,7 @@ endif()
set(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/lib)
link_directories(${LIBRARY_OUTPUT_PATH})

add_library(${Libname} ${Sources})
target_sources(${Libname} PRIVATE ${Sources})

target_link_libraries(${Libname} Threads::Threads)

Expand Down

0 comments on commit b84fb34

Please sign in to comment.