cmake produced makefile does install also LuaBridge includes when they are unwanted (inside other project)
ped7g opened this issue · 2 comments
ped7g commented
project: sjasmplus ( https://github.com/z00m128/sjasmplus )
using LuaBridge as git submodule
ISSUE:
make
builds the sjasmplus binary as expected, but make install
does install along sjasmplus also LuaBridge header files, which is not needed/wanted. (since 8068981 )
cmake configuration includes LuaBridge as
...
set(LUABRIDGE_DIR "LuaBridge/Source")
...
add_subdirectory(${LUABRIDGE_DIR})
...
target_link_libraries(
${PROJECT_NAME}
${LUA_LIBRARY}
LuaBridge
)
I hand-edited LuaBridge/Source/CMakelist.txt to:
# added debug messages
message(PROJECT_SOURCE_DIR="${PROJECT_SOURCE_DIR}")
message(CMAKE_SOURCE_DIR="${CMAKE_SOURCE_DIR}")
message(CMAKE_CURRENT_SOURCE_DIR="${CMAKE_CURRENT_SOURCE_DIR}")
# change in LuaBridge which is causing the issue
if(CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR)
install(DIRECTORY LuaBridge TYPE INCLUDE)
endif()
And during cmake configuration I get this output:
...
PROJECT_SOURCE_DIR="/home/ped/zx/sjasmplus"
CMAKE_SOURCE_DIR="/home/ped/zx/sjasmplus"
CMAKE_CURRENT_SOURCE_DIR="/home/ped/zx/sjasmplus/LuaBridge/Source"
...
I know very little about CMake, but should not be the change in LuaBridge like this instead:
if(CMAKE_CURRENT_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR)
install(DIRECTORY LuaBridge TYPE INCLUDE)
endif()
abouvier commented
Use EXCLUDE_FROM_ALL to skip unwanted targets/rules: add_subdirectory(${LUABRIDGE_DIR} EXCLUDE_FROM_ALL)
Otherwise, I reused the condition used elsewhere in the CMakeLists.txt
, it maybe wrong :p
ped7g commented
works for me, thank you.