Skip to content

Commit

Permalink
CMakeLists.txt: fix install on macOS if GNU coreutils are used (#203)
Browse files Browse the repository at this point in the history
* CMakeLists.txt: fix install on macOS if GNU coreutils are used

bsd ln supports both `-h` and `-n`, while GNU only supports `-n`.
In Nix we use GNU coreutils and hence the installation breaks.

Also see NixOS/nixpkgs#182909

With this patch installation will work with both variants of `ln`

* CMakeLists.txt: use CMAKE_INSTALL_FULL_INCLUDEDIR for header files

This allows to install header files in prefixes different from the rest.
We need this for nix as well.
  • Loading branch information
Mic92 committed Aug 17, 2022
1 parent 7f216e8 commit 4b6d2aa
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions CMakeLists.txt
Expand Up @@ -22,18 +22,18 @@ add_library(OpenCL::Headers ALIAS Headers)

if(CMAKE_SYSTEM_NAME MATCHES Darwin)
execute_process(
COMMAND ln -shf ${CMAKE_CURRENT_SOURCE_DIR}/CL ${CMAKE_CURRENT_BINARY_DIR}/CL
COMMAND ln -shf ${CMAKE_CURRENT_SOURCE_DIR}/CL ${CMAKE_CURRENT_BINARY_DIR}/OpenCL
COMMAND ln -snf ${CMAKE_CURRENT_SOURCE_DIR}/CL ${CMAKE_CURRENT_BINARY_DIR}/CL
COMMAND ln -snf ${CMAKE_CURRENT_SOURCE_DIR}/CL ${CMAKE_CURRENT_BINARY_DIR}/OpenCL
)
target_include_directories(Headers
INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
)
install(CODE "
file(MAKE_DIRECTORY ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_INCLUDEDIR}/CL)
file(MAKE_DIRECTORY ${CMAKE_INSTALL_FULL_INCLUDEDIR}/CL)
execute_process(
COMMAND ln -shf CL ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_INCLUDEDIR}/OpenCL
COMMAND ln -snf CL ${CMAKE_INSTALL_FULL_INCLUDEDIR}/OpenCL
)"
)
else()
Expand Down

0 comments on commit 4b6d2aa

Please sign in to comment.