]> granicus.if.org Git - esp-idf/commitdiff
cxx: force pthread to appear later in link line
authorRenz Christian Bagaporo <renz@espressif.com>
Tue, 17 Sep 2019 10:07:47 +0000 (18:07 +0800)
committerRenz Christian Bagaporo <renz@espressif.com>
Tue, 17 Sep 2019 12:08:12 +0000 (20:08 +0800)
components/cxx/CMakeLists.txt

index 4e81992ad0a8b77cdb1134f2eb1abe85382bb7e0..ff2d0e4389ecb5ef125b5a05e43e179e679bff4b 100644 (file)
@@ -1,9 +1,17 @@
 idf_component_register(SRCS "cxx_exception_stubs.cpp"
-                            "cxx_guards.cpp")
+                            "cxx_guards.cpp"
+                        # Make sure that pthread is in component list
+                        PRIV_REQUIRES pthread)
 
 target_link_libraries(${COMPONENT_LIB} PUBLIC stdc++ gcc)
 target_link_libraries(${COMPONENT_LIB} INTERFACE "-u __cxa_guard_dummy")
 
+# Force pthread to also appear later than stdc++ in link line
+add_library(stdcpp_pthread INTERFACE)
+idf_component_get_property(pthread pthread COMPONENT_LIB)
+target_link_libraries(stdcpp_pthread INTERFACE stdc++ $<TARGET_FILE:${pthread}>)
+target_link_libraries(${COMPONENT_LIB} PUBLIC stdcpp_pthread)
+
 if(NOT CONFIG_COMPILER_CXX_EXCEPTIONS)
     target_link_libraries(${COMPONENT_LIB} INTERFACE "-u __cxx_fatal_exception")
 endif()