Here's my CMakeLists.txt :

>>>>>>>

cmake_minimum_required(VERSION 3.8 FATAL_ERROR)
project(oscour)
set(CMAKE_INCLUDE_CURRENT_DIR ON)

set(CMAKE_CXX_FLAGS "-fconcepts -fsanitize=address -fsanitize=undefined")
set(CMAKE_EXE_LINKER_FLAGS "-fconcepts -fsanitize=address
-fsanitize=undefined")

add_subdirectory(uWebSockets)

find_package(Threads REQUIRED)

add_library(oscour INTERFACE)
target_sources(oscour INTERFACE
  ${CMAKE_CURRENT_SOURCE_DIR}/oscour/oscour.hpp)

target_include_directories(oscour INTERFACE oscour/)
target_link_libraries(oscour INTERFACE uWS Threads::Threads)
target_compile_options(oscour INTERFACE -std=c++17)

add_executable(udp examples/udp.cpp)
target_link_libraries(udp PRIVATE oscour)

add_executable(tcp examples/tcp.cpp)
target_link_libraries(tcp PRIVATE oscour)

<<<<<<<<

As you can see, I call
find_package(Threads REQUIRED)
but at no point my example executables, named udp and tcp, link to -pthread
(or -lpthread) (which of course makes my build fails).
I also tried to link them explicitely to Threads::Threads. This did not
work either.

e.g. when doing make in verbose mode, the link invocation is :

 /usr/bin/g++ -fconcepts -fsanitize=address -fsanitize=undefined -std=c++17
-fconcepts -fsanitize=address -fsanitize=undefined
CMakeFiles/complete.dir/examples/udp.cpp.o  -o udp  uWebSockets/libuWS.a
/usr/lib/libssl.so /usr/lib/libcrypto.so /usr/lib/libz.so

there is no hint of pthreads in there... what can I do ?

Best

Jean-Michaël Celerier
http://www.jcelerier.name
-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake

Reply via email to