Skip to content

Commit

Permalink
Merge pull request #2645 from Naios/symbolic_link_error_pr
Browse files Browse the repository at this point in the history
Fix cmake soft errors due to failing creation of links on windows
  • Loading branch information
hkaiser committed May 21, 2017
2 parents 88a829c + 0bb983f commit f7d8f26
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 15 deletions.
6 changes: 3 additions & 3 deletions CMakeLists.txt
Expand Up @@ -81,6 +81,7 @@ include(HPX_Libraries)
include(HPX_LibraryDir)
include(HPX_AddConfigTest)
include(HPX_AddDefinitions)
include(HPX_CreateSymbolicLink)

hpx_force_out_of_tree_build("This project requires an out-of-source-tree build. See README.rst. Clean your CMake cache and CMakeFiles if this message persists.")

Expand Down Expand Up @@ -1871,9 +1872,8 @@ endif()
include(HPX_GeneratePackage)

# Create a symlink in share pointing to the latest HPX installation
execute_process(COMMAND
"${CMAKE_COMMAND}" -E create_symlink "hpx-${HPX_VERSION}" "hpx"
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/share")
create_symbolic_link("${CMAKE_BINARY_DIR}/share/hpx-${HPX_VERSION}"
"${CMAKE_BINARY_DIR}/share/hpx")

message("")
message("HPX will be installed to ${CMAKE_INSTALL_PREFIX}")
Expand Down
21 changes: 21 additions & 0 deletions cmake/HPX_CreateSymbolicLink.cmake
@@ -0,0 +1,21 @@
# Copyright (c) 2017 Denis Blank
#
# Distributed under the Boost Software License, Version 1.0. (See accompanying
# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)

# Creates a symbolic link from the destination to the target,
# if the link doesn't exist yet.
# Since `create_symlink` is only available for unix derivates,
# we work around that in this macro.
macro(create_symbolic_link SYM_TARGET SYM_DESTINATION)
if(WIN32)
if(NOT EXISTS ${SYM_DESTINATION})
# Create a junction for windows links
execute_process(COMMAND cmd /C "${CMAKE_SOURCE_DIR}/cmake/scripts/create_symbolic_link.bat"
${SYM_DESTINATION} ${SYM_TARGET})
endif()
else()
# Only available on unix derivates
execute_process(COMMAND "${CMAKE_COMMAND}" -E create_symlink ${SYM_TARGET} ${SYM_DESTINATION})
endif()
endmacro(create_symbolic_link)
6 changes: 6 additions & 0 deletions cmake/scripts/create_symbolic_link.bat
@@ -0,0 +1,6 @@
:: Copyright (c) 2017 Denis Blank
::
:: Distributed under the Boost Software License, Version 1.0. (See accompanying
:: file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)

mklink /J "%1" "%2"
26 changes: 14 additions & 12 deletions docs/CMakeLists.txt
Expand Up @@ -381,20 +381,22 @@ endif()

# Create links to properly view the docs in the build directory
set(DOCS_OUTPUT_DIR "${CMAKE_BINARY_DIR}/share/hpx-${HPX_VERSION}/docs/html")

execute_process(COMMAND "${CMAKE_COMMAND}" -E make_directory "${DOCS_OUTPUT_DIR}" )
execute_process(COMMAND "${CMAKE_COMMAND}" -E make_directory "${DOCS_OUTPUT_DIR}/code" )
execute_process(
COMMAND "${CMAKE_COMMAND}" -E create_symlink "${PROJECT_SOURCE_DIR}/docs/html/src" "${DOCS_OUTPUT_DIR}/src")
execute_process(
COMMAND "${CMAKE_COMMAND}" -E create_symlink "${PROJECT_SOURCE_DIR}/docs/html/images" "${DOCS_OUTPUT_DIR}/images")
execute_process(
COMMAND "${CMAKE_COMMAND}" -E create_symlink "${PROJECT_SOURCE_DIR}/hpx" "${DOCS_OUTPUT_DIR}/code/hpx")
execute_process(
COMMAND "${CMAKE_COMMAND}" -E create_symlink "${PROJECT_SOURCE_DIR}/src" "${DOCS_OUTPUT_DIR}/code/src")
execute_process(
COMMAND "${CMAKE_COMMAND}" -E create_symlink "${PROJECT_SOURCE_DIR}/examples" "${DOCS_OUTPUT_DIR}/code/examples")
execute_process(
COMMAND "${CMAKE_COMMAND}" -E create_symlink "${PROJECT_SOURCE_DIR}/tests" "${DOCS_OUTPUT_DIR}/code/tests")

create_symbolic_link("${PROJECT_SOURCE_DIR}/docs/html/src"
"${DOCS_OUTPUT_DIR}/src")
create_symbolic_link("${PROJECT_SOURCE_DIR}/docs/html/images"
"${DOCS_OUTPUT_DIR}/images")
create_symbolic_link("${PROJECT_SOURCE_DIR}/hpx"
"${DOCS_OUTPUT_DIR}/code/hpx")
create_symbolic_link("${PROJECT_SOURCE_DIR}/src"
"${DOCS_OUTPUT_DIR}/code/src")
create_symbolic_link("${PROJECT_SOURCE_DIR}/examples"
"${DOCS_OUTPUT_DIR}/code/examples")
create_symbolic_link("${PROJECT_SOURCE_DIR}/tests"
"${DOCS_OUTPUT_DIR}/code/tests")

source_group(Documentation FILES ${base_files})
source_group("Documentation\\Manual" FILES ${manual_files})
Expand Down

0 comments on commit f7d8f26

Please sign in to comment.