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 CMake warning on macOS since CMake 3.9 #1371

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 11 additions & 3 deletions CMakeLists.txt
Expand Up @@ -25,6 +25,9 @@ set(CMAKE_LEGACY_CYGWIN_WIN32 0)
if(NOT CMAKE_VERSION VERSION_LESS 3.0)
cmake_policy(SET CMP0042 NEW)
endif()
if (NOT CMAKE_VERSION VERSION_LESS 3.9)
cmake_policy(SET CMP0068 NEW)
endif()

# add some default value for some additional macOS variable
# note that those variables are ignored on other systems
Expand Down Expand Up @@ -394,9 +397,14 @@ else()

# adapt install directory to allow distributing dylibs/frameworks in user's frameworks/application bundle
# NOTE: it's not required to link against SFML.framework
set_target_properties(SFML PROPERTIES
BUILD_WITH_INSTALL_RPATH 1
INSTALL_NAME_DIR "@rpath")
set_target_properties(SFML PROPERTIES INSTALL_NAME_DIR "@rpath")
if(NOT CMAKE_SKIP_BUILD_RPATH)
if (CMAKE_VERSION VERSION_LESS 3.9)
set_target_properties(${target} PROPERTIES BUILD_WITH_INSTALL_RPATH TRUE)
else()
set_target_properties(${target} PROPERTIES BUILD_WITH_INSTALL_NAME_DIR TRUE)
Comment on lines +403 to +405
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did we mean to use SFML here instead of ${target}? I can't find a variable defined with the name target in CMakeLists.txt. I just found this out because I started enforcing uninitialized variable warnings.

https://github.com/SFML/SFML/actions/runs/6859641809/job/18652242185#step:14:43

endif()
endif()

# install rule
install(TARGETS SFML
Expand Down
14 changes: 7 additions & 7 deletions cmake/Macros.cmake
Expand Up @@ -123,13 +123,13 @@ macro(sfml_add_library target)
# adapt install directory to allow distributing dylibs/frameworks in user's frameworks/application bundle
# but only if cmake rpath options aren't set
if(NOT CMAKE_SKIP_RPATH AND NOT CMAKE_SKIP_INSTALL_RPATH AND NOT CMAKE_INSTALL_RPATH AND NOT CMAKE_INSTALL_RPATH_USE_LINK_PATH AND NOT CMAKE_INSTALL_NAME_DIR)
if(CMAKE_SKIP_BUILD_RPATH)
set_target_properties(${target} PROPERTIES
INSTALL_NAME_DIR "@rpath")
else()
set_target_properties(${target} PROPERTIES
BUILD_WITH_INSTALL_RPATH 1
INSTALL_NAME_DIR "@rpath")
set_target_properties(${target} PROPERTIES INSTALL_NAME_DIR "@rpath")
if(NOT CMAKE_SKIP_BUILD_RPATH)
if (CMAKE_VERSION VERSION_LESS 3.9)
set_target_properties(${target} PROPERTIES BUILD_WITH_INSTALL_RPATH TRUE)
else()
set_target_properties(${target} PROPERTIES BUILD_WITH_INSTALL_NAME_DIR TRUE)
endif()
endif()
endif()
endif()
Expand Down