CMAKE- Object library target may not link to anything
up vote
0
down vote
favorite
I am getting an error with the cMakeLists.txt file below. The error is
Object library target "cm" may not link to anything.
The issue is with line target_link_libraries(cm corebase)
This builds OK on linux but I this error is occurring on windows.
I'd appreciate any ideas?
file(GLOB base
"*.cpp"
)
file (GLOB model
"*.cpp"
)
file(GLOB logger
"*.cpp"
)
file(GLOB pass
"*.cpp"
)
file(GLOB compiler
"src/compiler/*"
)
add_subdirectory(meta)
if (MSVC)
add_library(cm OBJECT ${compiler} ${pass})
add_library(corebase OBJECT ${base} ${logger})
add_library(model OBJECT ${model})
target_link_libraries(cm corebase)
add_dependencies(cm generate-comp-api)
add_dependencies(model generate-comp-api)
else()
add_library(cm SHARED ${base} ${logger} ${pass} ${compiler})
add_library(corebase SHARED ${base} ${logger})
add_library(model SHARED ${model})
target_link_libraries(cm corebase metamodel)
add_dependencies(cm generate-comp-api)
add_dependencies(model generate-comp-api)
add_subdirectory(python/api)
add_subdirectory(tests)
add_subdirectory(contrib/googletest)
#add_subdirectory(recordings)
endif(MSVC)
build cmake
add a comment |
up vote
0
down vote
favorite
I am getting an error with the cMakeLists.txt file below. The error is
Object library target "cm" may not link to anything.
The issue is with line target_link_libraries(cm corebase)
This builds OK on linux but I this error is occurring on windows.
I'd appreciate any ideas?
file(GLOB base
"*.cpp"
)
file (GLOB model
"*.cpp"
)
file(GLOB logger
"*.cpp"
)
file(GLOB pass
"*.cpp"
)
file(GLOB compiler
"src/compiler/*"
)
add_subdirectory(meta)
if (MSVC)
add_library(cm OBJECT ${compiler} ${pass})
add_library(corebase OBJECT ${base} ${logger})
add_library(model OBJECT ${model})
target_link_libraries(cm corebase)
add_dependencies(cm generate-comp-api)
add_dependencies(model generate-comp-api)
else()
add_library(cm SHARED ${base} ${logger} ${pass} ${compiler})
add_library(corebase SHARED ${base} ${logger})
add_library(model SHARED ${model})
target_link_libraries(cm corebase metamodel)
add_dependencies(cm generate-comp-api)
add_dependencies(model generate-comp-api)
add_subdirectory(python/api)
add_subdirectory(tests)
add_subdirectory(contrib/googletest)
#add_subdirectory(recordings)
endif(MSVC)
build cmake
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I am getting an error with the cMakeLists.txt file below. The error is
Object library target "cm" may not link to anything.
The issue is with line target_link_libraries(cm corebase)
This builds OK on linux but I this error is occurring on windows.
I'd appreciate any ideas?
file(GLOB base
"*.cpp"
)
file (GLOB model
"*.cpp"
)
file(GLOB logger
"*.cpp"
)
file(GLOB pass
"*.cpp"
)
file(GLOB compiler
"src/compiler/*"
)
add_subdirectory(meta)
if (MSVC)
add_library(cm OBJECT ${compiler} ${pass})
add_library(corebase OBJECT ${base} ${logger})
add_library(model OBJECT ${model})
target_link_libraries(cm corebase)
add_dependencies(cm generate-comp-api)
add_dependencies(model generate-comp-api)
else()
add_library(cm SHARED ${base} ${logger} ${pass} ${compiler})
add_library(corebase SHARED ${base} ${logger})
add_library(model SHARED ${model})
target_link_libraries(cm corebase metamodel)
add_dependencies(cm generate-comp-api)
add_dependencies(model generate-comp-api)
add_subdirectory(python/api)
add_subdirectory(tests)
add_subdirectory(contrib/googletest)
#add_subdirectory(recordings)
endif(MSVC)
build cmake
I am getting an error with the cMakeLists.txt file below. The error is
Object library target "cm" may not link to anything.
The issue is with line target_link_libraries(cm corebase)
This builds OK on linux but I this error is occurring on windows.
I'd appreciate any ideas?
file(GLOB base
"*.cpp"
)
file (GLOB model
"*.cpp"
)
file(GLOB logger
"*.cpp"
)
file(GLOB pass
"*.cpp"
)
file(GLOB compiler
"src/compiler/*"
)
add_subdirectory(meta)
if (MSVC)
add_library(cm OBJECT ${compiler} ${pass})
add_library(corebase OBJECT ${base} ${logger})
add_library(model OBJECT ${model})
target_link_libraries(cm corebase)
add_dependencies(cm generate-comp-api)
add_dependencies(model generate-comp-api)
else()
add_library(cm SHARED ${base} ${logger} ${pass} ${compiler})
add_library(corebase SHARED ${base} ${logger})
add_library(model SHARED ${model})
target_link_libraries(cm corebase metamodel)
add_dependencies(cm generate-comp-api)
add_dependencies(model generate-comp-api)
add_subdirectory(python/api)
add_subdirectory(tests)
add_subdirectory(contrib/googletest)
#add_subdirectory(recordings)
endif(MSVC)
build cmake
build cmake
edited Nov 21 at 16:48
asked Nov 21 at 16:29
catha catriona
11
11
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
up vote
0
down vote
The error message is correct: OBJECT libraries shouldn't link to anything. Instead, one need to use object files, corresponded to the library, as source files for executable/other library:
# Create an OBJECT library
add_library(corebase OBJECT ${base} ${logger})
# And use its objects for other library.
add_library(cm OBJECT ${compiler} ${pass} $<TARGET_OBJECTS:corebase>)
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
The error message is correct: OBJECT libraries shouldn't link to anything. Instead, one need to use object files, corresponded to the library, as source files for executable/other library:
# Create an OBJECT library
add_library(corebase OBJECT ${base} ${logger})
# And use its objects for other library.
add_library(cm OBJECT ${compiler} ${pass} $<TARGET_OBJECTS:corebase>)
add a comment |
up vote
0
down vote
The error message is correct: OBJECT libraries shouldn't link to anything. Instead, one need to use object files, corresponded to the library, as source files for executable/other library:
# Create an OBJECT library
add_library(corebase OBJECT ${base} ${logger})
# And use its objects for other library.
add_library(cm OBJECT ${compiler} ${pass} $<TARGET_OBJECTS:corebase>)
add a comment |
up vote
0
down vote
up vote
0
down vote
The error message is correct: OBJECT libraries shouldn't link to anything. Instead, one need to use object files, corresponded to the library, as source files for executable/other library:
# Create an OBJECT library
add_library(corebase OBJECT ${base} ${logger})
# And use its objects for other library.
add_library(cm OBJECT ${compiler} ${pass} $<TARGET_OBJECTS:corebase>)
The error message is correct: OBJECT libraries shouldn't link to anything. Instead, one need to use object files, corresponded to the library, as source files for executable/other library:
# Create an OBJECT library
add_library(corebase OBJECT ${base} ${logger})
# And use its objects for other library.
add_library(cm OBJECT ${compiler} ${pass} $<TARGET_OBJECTS:corebase>)
answered Nov 21 at 22:02
Tsyvarev
25.1k32455
25.1k32455
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53416527%2fcmake-object-library-target-may-not-link-to-anything%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown