diff --git a/CMakeLists.txt b/CMakeLists.txt index a4cfa0b59ad85..3c6eda39db04d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -165,6 +165,15 @@ else(MSVC) set(CMAKE_CXX_FLAGS "-faligned-new ${CMAKE_CXX_FLAGS}") endif() + # ld option to warn if symbols are undefined (e.g. libtvm_runtime.so + # using symbols only present in libtvm.so). Not needed for MSVC, + # since this is already the default there. + if(CMAKE_SYSTEM_NAME EQUAL "Darwin") + set(CMAKE_SHARED_LINKER_FLAGS "-Wl,-undefined,error ${CMAKE_SHARED_LINKER_FLAGS}") + else() + set(CMAKE_SHARED_LINKER_FLAGS "-Wl,--no-undefined ${CMAKE_SHARED_LINKER_FLAGS}") + endif() + # Detect if we're compiling for Hexagon. set(TEST_FOR_HEXAGON_CXX "#ifndef __hexagon__"