Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a target_link_libraries() usage example to Corrade CMake docs #113

Open
mgood7123 opened this issue Mar 3, 2021 · 2 comments
Open
Milestone

Comments

@mgood7123
Copy link

mgood7123 commented Mar 3, 2021

I followed the instructions from

https://doc.magnum.graphics/corrade/corrade-cmake.html#corrade-cmake-subproject

the test case is https://github.com/mgood7123/Dummy

when building I get

-- Found Corrade: /Users/smallville7123/Desktop/Dummy/corrade/src  found components: Containers rc Utility
CMake Error at CMakeLists.txt:26 (target_link_libraries):
  Target "Corrade" of type UTILITY may not be linked into another target.
  One may link only to INTERFACE, OBJECT, STATIC or SHARED libraries, or to
  executables with the ENABLE_EXPORTS property set.

the CMakeFile is https://github.com/mgood7123/Dummy/blob/main/CMakeLists.txt

cmake_minimum_required(VERSION 3.4.1)

project(Dummy)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

# https://doc.magnum.graphics/corrade/corrade-cmake.html#corrade-cmake-subproject

set(WITH_CONTAINERS ON CACHE BOOL "" FORCE)
set(WITH_PLUGINMANAGER OFF CACHE BOOL "" FORCE)
set(WITH_UTILITY ON CACHE BOOL "" FORCE)
set(WITH_TESTSUITE OFF CACHE BOOL "" FORCE)
set(WITH_RC OFF CACHE BOOL "" FORCE)
add_subdirectory(corrade EXCLUDE_FROM_ALL)

# Path where FindCorrade.cmake can be found, adapt as needed
set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/corrade/modules/" ${CMAKE_MODULE_PATH})
find_package(Corrade REQUIRED Utility Containers)

include_directories(corrade/src)
add_library(Dummy SHARED src/dummy.cpp)
if (ANDROID)
    target_link_libraries(Dummy Corrade Corrade::Containers Corrade::Utility android log)
else()
    target_link_libraries(Dummy Corrade Corrade::Containers Corrade::Utility)
endif()

this happens even if I disable everything

cmake_minimum_required(VERSION 3.4.1)

project(Dummy)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

# https://doc.magnum.graphics/corrade/corrade-cmake.html#corrade-cmake-subproject

set(WITH_CONTAINERS OFF CACHE BOOL "" FORCE)
set(WITH_PLUGINMANAGER OFF CACHE BOOL "" FORCE)
set(WITH_UTILITY OFF CACHE BOOL "" FORCE)
set(WITH_TESTSUITE OFF CACHE BOOL "" FORCE)
set(WITH_RC OFF CACHE BOOL "" FORCE)

add_subdirectory(corrade EXCLUDE_FROM_ALL)

# Path where FindCorrade.cmake can be found, adapt as needed
set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/corrade/modules/" ${CMAKE_MODULE_PATH})
find_package(Corrade REQUIRED)

include_directories(corrade/src)
add_library(Dummy SHARED src/dummy.cpp)
if (ANDROID)
    target_link_libraries(Dummy Corrade android log)
else()
    target_link_libraries(Dummy Corrade)
endif()

what could I be doing incorrectly?

@mgood7123 mgood7123 changed the title make subproject clarification make subproject clarification (Target "Corrade" of type UTILITY may not be linked into another target.) Mar 3, 2021
@mosra mosra changed the title make subproject clarification (Target "Corrade" of type UTILITY may not be linked into another target.) Add a target_link_libraries() usage example to Corrade CMake docs Mar 3, 2021
@mosra mosra added this to the 2020.0b milestone Mar 3, 2021
@mosra
Copy link
Owner

mosra commented Mar 3, 2021

(Solved on Gitter in the meantime.)

I'll update the docs to show an example target_link_libraries() for this to avoid mistakes with linking just Corrade, all other libs have it already so why not here.

@mgood7123
Copy link
Author

(Solved on Gitter in the meantime.)

I'll update the docs to show an example target_link_libraries() for this to avoid mistakes with linking just Corrade, all other libs have it already so why not here.

thanks :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Development

No branches or pull requests

2 participants