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

fix(CMakeLists): build fails when using cmake on mac with Xcode as ge… #949

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -495,6 +495,22 @@ target_compile_features (glog_internal PUBLIC $<TARGET_PROPERTY:glog,COMPILE_FEA
add_library (glog
$<TARGET_OBJECTS:glog_internal>
)

# Note: When you use cmake to build with xcode as a generator under Mac, the build will fail.
# See https://cmake.org/cmake/help/latest/command/add_library.html#object-libraries
if(CMAKE_GENERATOR STREQUAL "Xcode")
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp)
set(temporary_file "${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/xcode.cpp")

add_custom_command(
OUTPUT ${temporary_file}
COMMAND ${CMAKE_COMMAND} -E touch ${temporary_file}
COMMENT "Creating temporary files for building on Xcode"
)

target_sources(glog PRIVATE $<$<BOOL:${temporary_file}>:${temporary_file}>)
endif(CMAKE_GENERATOR STREQUAL "Xcode")

target_compile_features (glog PUBLIC cxx_std_14)

add_library (glog::glog ALIAS glog)
Expand Down
Loading