Hi CMake community,
I got a small piece of code where set_target_properties
doesn’t work as expected.
add_compile_definitions(
TARGET_NAME="PluginInterface"
DEBUG_PREFIX="PluginInterface"
)
add_llvm_library(PluginInterface OBJECT
PluginInterface.cpp GlobalHandler.cpp
BUILDTREE_ONLY
LINK_COMPONENTS
Support
LINK_LIBS
PRIVATE
elf_common
MemoryManager
)
set_target_properties(PluginInterface PROPERTIES
POSITION_INDEPENDENT_CODE ON
CXX_VISIBILITY_PRESET protected)
target_include_directories(PluginInterface INTERFACE ${CMAKE_CURRENT_SOURCE_DIR})
target_include_directories(PluginInterface PRIVATE ${LIBOMPTARGET_INCLUDE_DIR})
I set CXX_VISIBILITY_PRESET
of the target PluginInterface
to protected
. It is expected to have -fvisibility=protected
when the two cpp files are compiled. However, -fvisibility=protected
doesn’t exist. Of course -fPIC
neither. If I replace add_llvm_library
with add_library
, and of course remove those arguments that add_library
doesn’t recognize, things work pretty fine.
I’m wondering what could potentially cause this issue, and what I should look into add_llvm_library
. I did use cmake_print_properties
on PluginInterface
and CXX_VISIBILITY_PRESET
is properly set, but just not in the compile flags. Any suggestion would be appreciated. Thanks!