-
Notifications
You must be signed in to change notification settings - Fork 106
Open
Description
When Xcode is used as generator, i.e., cmake -G Xcode -S ... -B ..., static and shared libraries are not built using generated project.
The issue is caused by CMake Object Libraries with no source files.
Quote from add_library() documentation:
Some native build systems (such as Xcode) may not like targets that have only object files, so consider adding at least one real source file to any target that references $<TARGET_OBJECTS:objlib>.
Addition of a dummy source files to the corresponding targets fixes the issue.
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 2e8e07e..b9783b9 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -66,11 +66,11 @@ set(INSTALL_HEADERS "${PROJECT_BINARY_DIR}/include/correct.h")
add_custom_target(correct-h ALL COMMAND ${CMAKE_COMMAND} -E copy ${PROJECT_SOURCE_DIR}/include/correct.h ${PROJECT_BINARY_DIR}/include/correct.h)
if(HAVE_SSE)
- set(correct_obj_files $<TARGET_OBJECTS:correct-reed-solomon> $<TARGET_OBJECTS:correct-convolutional> $<TARGET_OBJECTS:correct-convolutional-sse>)
+ set(correct_obj_files src/dummy.c $<TARGET_OBJECTS:correct-reed-solomon> $<TARGET_OBJECTS:correct-convolutional> $<TARGET_OBJECTS:correct-convolutional-sse>)
set(INSTALL_HEADERS ${INSTALL_HEADERS} ${PROJECT_BINARY_DIR}/include/correct-sse.h)
add_custom_target(correct-sse-h ALL COMMAND ${CMAKE_COMMAND} -E copy ${PROJECT_SOURCE_DIR}/include/correct-sse.h ${PROJECT_BINARY_DIR}/include/correct-sse.h)
else()
- set(correct_obj_files $<TARGET_OBJECTS:correct-reed-solomon> $<TARGET_OBJECTS:correct-convolutional>)
+ set(correct_obj_files src/dummy.c $<TARGET_OBJECTS:correct-reed-solomon> $<TARGET_OBJECTS:correct-convolutional>)
endif()
add_library(correct SHARED ${correct_obj_files})
add_library(correct_static ${correct_obj_files})
diff --git a/src/dummy.c b/src/dummy.c
new file mode 100644
index 0000000..e04b961
--- /dev/null
+++ b/src/dummy.c
@@ -0,0 +1,4 @@
+
+void empty_function(void)
+{
+}Metadata
Metadata
Assignees
Labels
No labels