From b84fb344b1b77ef837602fb631383f85398b750f Mon Sep 17 00:00:00 2001 From: Michael Ilyin Date: Thu, 31 Aug 2023 14:17:28 +0200 Subject: [PATCH] cmake compiler opts and lib dependency fixes --- CMakeLists.txt | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 80a2cc2f8..da060a2c0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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( - $<$:-pipe -O3> - $<$:-Wall -Wextra -Werror -Wpedantic -Wunused -Wstrict-prototypes -pipe -g -O0> + "$<$:${release_opts}>" + "$<$:${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" @@ -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" @@ -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)