Skip to content

Commit

Permalink
CMake: New Hints as Generator Expressions
Browse files Browse the repository at this point in the history
  • Loading branch information
ax3l committed Feb 11, 2021
1 parent a66ce69 commit be51b6f
Showing 1 changed file with 12 additions and 27 deletions.
39 changes: 12 additions & 27 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -952,6 +952,12 @@ if(openPMD_BUILD_TESTING)
${MPIEXEC_NUMPROC_FLAG} 2
)

# preserve Windows environment for runtime tests
if(WIN32)
string(REPLACE ";" "\\;" WIN_PATH "$ENV{PATH}")
string(REPLACE ";" "\\;" WIN_PYTHONPATH "$ENV{PYTHONPATH}")
endif()

# do we have openPMD-example-datasets?
if(EXISTS "${openPMD_BINARY_DIR}/samples/git-sample/")
set(EXAMPLE_DATA_FOUND ON)
Expand Down Expand Up @@ -1014,17 +1020,10 @@ if(openPMD_BUILD_TESTING)
${CMAKE_RUNTIME_OUTPUT_DIRECTORY}
)
if(WIN32)
string(REGEX REPLACE "/" "\\\\" WIN_BUILD_PYDIR ${CMAKE_PYTHON_OUTPUT_DIRECTORY})
string(REGEX REPLACE "/" "\\\\" WIN_BUILD_BINDIR ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
string(REGEX REPLACE "/" "\\\\" WIN_LIB_BINDIR ${CMAKE_LIBRARY_OUTPUT_DIRECTORY})
string(REPLACE ";" "\\;" WIN_PATH "$ENV{PATH}")
string(REPLACE ";" "\\;" WIN_PYTHONPATH "$ENV{PYTHONPATH}")
message(STATUS "PATH=${WIN_BUILD_BINDIR}\;${WIN_LIB_BINDIR}\;${WIN_PATH}\n")
message(STATUS "PYTHONPATH=${WIN_BUILD_PYDIR}\;${WIN_PYTHONPATH}")
set_property(TEST Unittest.py
PROPERTY ENVIRONMENT
"PATH=${WIN_BUILD_BINDIR}\;${WIN_LIB_BINDIR}\;${WIN_PATH}\n"
"PYTHONPATH=${WIN_BUILD_PYDIR}\;${WIN_PYTHONPATH}"
"PATH=$<SHELL_PATH:$<TARGET_FILE_DIR:openPMD>>\;${WIN_PATH}\n"
"PYTHONPATH=${CMAKE_PYTHON_OUTPUT_DIRECTORY}\;${WIN_PYTHONPATH}"
)
else()
set_tests_properties(Unittest.py
Expand Down Expand Up @@ -1095,17 +1094,10 @@ if(openPMD_BUILD_TESTING)
WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}
)
if(WIN32)
string(REGEX REPLACE "/" "\\\\" WIN_BUILD_PYDIR ${CMAKE_PYTHON_OUTPUT_DIRECTORY})
string(REGEX REPLACE "/" "\\\\" WIN_BUILD_BINDIR ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
string(REGEX REPLACE "/" "\\\\" WIN_LIB_BINDIR ${CMAKE_LIBRARY_OUTPUT_DIRECTORY})
string(REPLACE ";" "\\;" WIN_PATH "$ENV{PATH}")
string(REPLACE ";" "\\;" WIN_PYTHONPATH "$ENV{PYTHONPATH}")
message(STATUS "PATH=${WIN_BUILD_BINDIR}\;${WIN_LIB_BINDIR}\;${WIN_PATH}\n")
message(STATUS "PYTHONPATH=${WIN_BUILD_PYDIR}\;${WIN_PYTHONPATH}")
set_property(TEST CLI.py.help.${pymodulename}
PROPERTY ENVIRONMENT
"PATH=${WIN_BUILD_BINDIR}\;${WIN_LIB_BINDIR}\;${WIN_PATH}\n"
"PYTHONPATH=${WIN_BUILD_PYDIR}\;${WIN_PYTHONPATH}"
"PATH=$<SHELL_PATH:$<TARGET_FILE_DIR:openPMD>>\;${WIN_PATH}\n"
"PYTHONPATH=${CMAKE_PYTHON_OUTPUT_DIRECTORY}\;${WIN_PYTHONPATH}"
)
else()
set_tests_properties(CLI.py.help.${pymodulename}
Expand Down Expand Up @@ -1147,17 +1139,10 @@ if(openPMD_BUILD_TESTING)
)
endif()
if(WIN32)
string(REGEX REPLACE "/" "\\\\" WIN_BUILD_PYDIR ${CMAKE_PYTHON_OUTPUT_DIRECTORY})
string(REGEX REPLACE "/" "\\\\" WIN_BUILD_BINDIR ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
string(REGEX REPLACE "/" "\\\\" WIN_LIB_BINDIR ${CMAKE_LIBRARY_OUTPUT_DIRECTORY})
string(REPLACE ";" "\\;" WIN_PATH "$ENV{PATH}")
string(REPLACE ";" "\\;" WIN_PYTHONPATH "$ENV{PYTHONPATH}")
message(STATUS "PATH=${WIN_BUILD_BINDIR}\;${WIN_LIB_BINDIR}\;${WIN_PATH}\n")
message(STATUS "PYTHONPATH=${WIN_BUILD_PYDIR}\;${WIN_PYTHONPATH}")
set_property(TEST Example.py.${examplename}
PROPERTY ENVIRONMENT
"PATH=${WIN_BUILD_BINDIR}\;${WIN_LIB_BINDIR}\;${WIN_PATH}\n"
"PYTHONPATH=${WIN_BUILD_PYDIR}\;${WIN_PYTHONPATH}"
"PATH=$<SHELL_PATH:$<TARGET_FILE_DIR:openPMD>>\;${WIN_PATH}\n"
"PYTHONPATH=${CMAKE_PYTHON_OUTPUT_DIRECTORY}\;${WIN_PYTHONPATH}"
)
else()
set_tests_properties(Example.py.${examplename}
Expand Down

0 comments on commit be51b6f

Please sign in to comment.