Skip to content

Commit

Permalink
Merge pull request mlpack#3827 from rcurtin/better-cross-compile-fail…
Browse files Browse the repository at this point in the history
…-output

Better cross-compilation failure output
  • Loading branch information
shrit authored Nov 15, 2024
2 parents dbaa0a5 + d9f992c commit 4653e10
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
21 changes: 21 additions & 0 deletions CMake/ConfigureCrossCompile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,27 @@ if (CMAKE_CROSSCOMPILING)
elseif(NOT TOOLCHAIN_PREFIX)
message(FATAL_ERROR "Cannot configure: TOOLCHAIN_PREFIX must be set when performing cross-compiling!")
endif()

# Now make sure that we can still compile a simple test program.
# (This ensures we didn't add any bad CXXFLAGS.)
# Note that OUTPUT_VARIABLE is only available in newer versions of CMake!
# CMake 3.23 (silently) introduced the variable.
include(CheckCXXSourceCompiles)
if (CMAKE_VERSION VERSION_LESS "3.22.0")
check_cxx_source_compiles("int main() { return 0; }" COMPILE_SUCCESS)
if (NOT COMPILE_SUCCESS)
message(FATAL_ERROR "The C++ cross-compiler at ${CMAKE_CXX_COMPILER} is "
"not able to compile a trivial test program. Check the CXXFLAGS!")
endif ()
else ()
check_cxx_source_compiles("int main() { return 0; }" COMPILE_SUCCESS
OUTPUT_VARIABLE COMPILE_OUTPUT)
if (NOT COMPILE_SUCCESS)
message(FATAL_ERROR "The C++ cross-compiler at ${CMAKE_CXX_COMPILER} is "
"not able to compile a trivial test program. Compiler output:\n\n"
"${COMPILE_OUTPUT}")
endif ()
endif ()
endif()

macro(search_openblas version)
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ endif()
# Download and compile OpenBLAS if we are cross compiling mlpack for a specific
# architecture. The function takes the version of OpenBLAS as variable.
if (CMAKE_CROSSCOMPILING)
search_openblas(0.3.26)
search_openblas(0.3.28)
endif()

if (NOT DOWNLOAD_DEPENDENCIES)
Expand Down

0 comments on commit 4653e10

Please sign in to comment.