Skip to content

Commit a426966

Browse files
committed
Make CMake, project build & test more robust on Windows
If you have Git-Bash's bash.exe in the front of your path, you can now do everything from within the Intel OneAPI CMD.exe shell. If you experience issues you should launch git-bash from the OneAPI CMD.exe shell and it will inherit your environment variables and be more robust. If CMake finds WSL, you're probably hosed.
1 parent 6b2c49a commit a426966

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

CMakeLists.txt

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -548,6 +548,10 @@ if(APPLE)
548548
find_program(CODESIGN codesign)
549549
endif()
550550

551+
# We need bash, even on windows, for now at least. A light version like Git-Bash works best,
552+
# WSL dumps you into your home directory and there's nothing you can do about it.
553+
find_program(BASH_EXECUTABLE bash
554+
REQUIRED)
551555
function(caf_compile_executable target main_depend)
552556
set(includes "")
553557
foreach(includedir ${MPI_Fortran_INCLUDE_DIRS})
@@ -561,7 +565,7 @@ function(caf_compile_executable target main_depend)
561565
list(APPEND localDefs "-D${d}")
562566
endforeach()
563567
add_custom_command(OUTPUT "${target}"
564-
COMMAND "${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_BINDIR}/caf"
568+
COMMAND "${BASH_EXECUTABLE}" "${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_BINDIR}/caf"
565569
${includes} ${localDefs} ${config_Fortran_flags}
566570
-o "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${target}"
567571
"${CMAKE_CURRENT_SOURCE_DIR}/${main_depend}"
@@ -720,9 +724,9 @@ function(add_caf_test name num_caf_img test_target)
720724
endif()
721725
set(test_parameters -np ${num_caf_img} ${test_parameters})
722726
if(DEFINED ARGN)
723-
add_test(NAME ${name} COMMAND "bash" "${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_BINDIR}/cafrun" ${test_parameters} "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${test_target}" ${ARGN})
727+
add_test(NAME ${name} COMMAND "${BASH_EXECUTABLE}" "${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_BINDIR}/cafrun" ${test_parameters} "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${test_target}" ${ARGN})
724728
else()
725-
add_test(NAME ${name} COMMAND "bash" "${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_BINDIR}/cafrun" ${test_parameters} "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${test_target}")
729+
add_test(NAME ${name} COMMAND "${BASH_EXECUTABLE}" "${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_BINDIR}/cafrun" ${test_parameters} "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${test_target}")
726730
endif()
727731
set_property(TEST ${name} PROPERTY PASS_REGULAR_EXPRESSION "Test passed.")
728732
endfunction(add_caf_test)

cmake/AddInstallationScriptTest.cmake

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@ macro(add_installation_script_test name path)
88
file( COPY "${CMAKE_CURRENT_SOURCE_DIR}/${path}/${name}-usage" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/${path}"
99
FILE_PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
1010
)
11-
add_test(NAME test-${name} COMMAND "${CMAKE_BINARY_DIR}/${path}/${name}")
12-
set_property(TEST test-${name} PROPERTY WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/${path}")
13-
set_property(TEST test-${name} PROPERTY ENVIRONMENT "OPENCOARRAYS_SRC_DIR=${CMAKE_SOURCE_DIR}")
11+
if(EXISTS ${BASH_EXECUTABLE})
12+
message(STATUS "Bash executable found: ${BASH_EXECUTABLE}")
13+
add_test(NAME test-${name} COMMAND "${BASH_EXECUTABLE}" "${CMAKE_BINARY_DIR}/${path}/${name}")
14+
set_property(TEST test-${name} PROPERTY WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/${path}")
15+
set_property(TEST test-${name} PROPERTY ENVIRONMENT "OPENCOARRAYS_SRC_DIR=${CMAKE_SOURCE_DIR}")
16+
endif()
1417
endmacro(add_installation_script_test)

0 commit comments

Comments
 (0)