Skip to content
This repository was archived by the owner on May 9, 2024. It is now read-only.

Commit cf63bb3

Browse files
gshimanskyalexbaden
authored andcommitted
Fixed "cmake install" on windows
Signed-off-by: Gregory Shimansky <[email protected]>
1 parent c7c771d commit cf63bb3

File tree

3 files changed

+28
-5
lines changed

3 files changed

+28
-5
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ if(DEFINED ENV{CONDA_PREFIX})
6565
set(ENABLE_CONDA ON)
6666
set(CMAKE_SYSROOT "$ENV{CONDA_BUILD_SYSROOT}")
6767
list(APPEND CMAKE_PREFIX_PATH "$ENV{CONDA_PREFIX}")
68-
set(CMAKE_INSTALL_PREFIX "$ENV{CONDA_PREFIX}")
68+
file(TO_CMAKE_PATH "$ENV{CONDA_PREFIX}" CMAKE_INSTALL_PREFIX)
6969
endif()
7070

7171
string(TIMESTAMP HDK_BUILD_DATE "%Y%m%d")

python/CMakeLists.txt

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@ set(SETUP_PY "${CMAKE_CURRENT_BINARY_DIR}/setup.py")
33
get_property(CDEFS DIRECTORY PROPERTY COMPILE_DEFINITIONS)
44
get_property(IDIRS DIRECTORY PROPERTY INCLUDE_DIRECTORIES)
55

6+
# On windows setup.py for some reason is unable to work with
7+
# cmake-style path with forward slashes. It requires native path
8+
# with back slashes in definition of package_dir variable.
9+
file(TO_NATIVE_PATH "${CMAKE_CURRENT_SOURCE_DIR}" NATIVE_CMAKE_CURRENT_SOURCE_DIR)
10+
string(REPLACE "\\" "\\\\" NATIVE_CMAKE_CURRENT_SOURCE_DIR ${NATIVE_CMAKE_CURRENT_SOURCE_DIR})
611
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/setup.py.in" "${SETUP_PY}")
712
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/pyhdk/version.py.in" "${CMAKE_CURRENT_SOURCE_DIR}/pyhdk/version.py")
813

@@ -22,9 +27,20 @@ set(pydeps
2227

2328
# $<SEMICOLON> is used here as a list separator and it is converted to colon ":" on Linux in $<SHELL_PATH>
2429
# expression.
25-
set(SETUP_LDFLAGS $<TARGET_FILE_DIR:Calcite>$<SEMICOLON>$<TARGET_FILE_DIR:IR>$<SEMICOLON>$<TARGET_FILE_DIR:ArrowStorage>$<SEMICOLON>$<TARGET_FILE_DIR:QueryBuilder>$<SEMICOLON>$<TARGET_FILE_DIR:QueryEngine>$<SEMICOLON>$<TARGET_FILE_DIR:SchemaMgr>$<SEMICOLON>$<TARGET_FILE_DIR:ConfigBuilder>$<SEMICOLON>$<TARGET_FILE_DIR:Logger>$<SEMICOLON>$<TARGET_FILE_DIR:Shared>$<SEMICOLON>$<TARGET_FILE_DIR:DataMgr>$<SEMICOLON>$<TARGET_FILE_DIR:ResultSet>$<SEMICOLON>$<TARGET_FILE_DIR:ResultSetRegistry>$<SEMICOLON>$<TARGET_FILE_DIR:${Boost_LOG_LIBRARY}>)
30+
set(SETUP_LD_PATH_LIST $<TARGET_FILE_DIR:Calcite>$<SEMICOLON>$<TARGET_FILE_DIR:IR>$<SEMICOLON>$<TARGET_FILE_DIR:ArrowStorage>$<SEMICOLON>$<TARGET_FILE_DIR:QueryBuilder>$<SEMICOLON>$<TARGET_FILE_DIR:QueryEngine>$<SEMICOLON>$<TARGET_FILE_DIR:SchemaMgr>$<SEMICOLON>$<TARGET_FILE_DIR:ConfigBuilder>$<SEMICOLON>$<TARGET_FILE_DIR:Logger>$<SEMICOLON>$<TARGET_FILE_DIR:Shared>$<SEMICOLON>$<TARGET_FILE_DIR:DataMgr>$<SEMICOLON>$<TARGET_FILE_DIR:ResultSet>$<SEMICOLON>$<TARGET_FILE_DIR:ResultSetRegistry>$<SEMICOLON>$<TARGET_FILE_DIR:${Boost_LOG_LIBRARY}>)
2631

27-
set(SETUP_FLAGS -f -I ${CMAKE_CURRENT_SOURCE_DIR} -L "$<SHELL_PATH:${SETUP_LDFLAGS}>")
32+
if (WIN32)
33+
# Convert all paths from library list to paths with forward
34+
# slashes. This is required because on windows paths with back slashes
35+
# work incorrectly in cmake_install.cmake since cmake thinks that
36+
# those are quoted characters.
37+
cmake_path(CONVERT ${SETUP_LD_PATH_LIST} TO_CMAKE_PATH_LIST SETUP_LDFLAGS)
38+
else()
39+
# Convert semicolons from the list above into colons path separator
40+
# on Linux.
41+
set(SETUP_LDFLAGS "$<SHELL_PATH:${SETUP_LD_PATH_LIST}>")
42+
endif()
43+
set(SETUP_FLAGS -f -I ${CMAKE_CURRENT_SOURCE_DIR} -L ${SETUP_LDFLAGS})
2844

2945
if (NOT WIN32 AND (CMAKE_BUILD_TYPE STREQUAL "Debug" OR CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo"))
3046
# On windows enabling debug in python requires python debug library which is absent in conda
@@ -45,4 +61,11 @@ add_custom_target(pyhdk-install
4561
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
4662
)
4763

48-
install(CODE "execute_process(WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} COMMAND ${Python3_EXECUTABLE} ${SETUP_PY} build_ext ${SETUP_FLAGS} install)")
64+
# On windows we cannot use variable ${SETUP_FLAGS} in the line below
65+
# because it has all delimiting spaces converted to semicolons while
66+
# we need spaces between arguments and semicolons in library
67+
# list. Therefore repeat all arguments from ${SETUP_FLAGS} here. Also
68+
# quotes are required around ${SETUP_LDFLAGS} because otherwise cmake
69+
# converts semicolons to spaces when executing
70+
# cmake_install.cmake. This stuff is very fragile, touch with care!
71+
install(CODE "execute_process(WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} COMMAND ${Python3_EXECUTABLE} ${SETUP_PY} build_ext -f -I ${CMAKE_CURRENT_SOURCE_DIR} -L \"${SETUP_LDFLAGS}\" install)")

python/setup.py.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ setup(
156156
name="pyhdk",
157157
version="@HDK_VERSION_RAW@",
158158
packages=["pyhdk"],
159-
package_dir={"pyhdk": "@CMAKE_CURRENT_SOURCE_DIR@/pyhdk"},
159+
package_dir={"pyhdk": os.path.join("@NATIVE_CMAKE_CURRENT_SOURCE_DIR@", "pyhdk")},
160160
ext_modules=cythonize(
161161
[common, execute, sql, storage, ir, builder],
162162
compiler_directives={

0 commit comments

Comments
 (0)