File tree Expand file tree Collapse file tree 1 file changed +23
-1
lines changed Expand file tree Collapse file tree 1 file changed +23
-1
lines changed Original file line number Diff line number Diff line change @@ -479,11 +479,33 @@ if (DEPS_DIR)
479
479
endif ()
480
480
endif ()
481
481
482
+ # Find libraries when cross-compiling on Linux systems.
483
+ # We purposedly do not use the `LINUX` variable for two reasons:
484
+ # - We're not testing for the target but for the system running the compiler,
485
+ # - It should exclude Android.
486
+ if (CMAKE_SYSTEM_NAME MATCHES "Linux" )
487
+ # This code setting MACHINE_TRIPLE may be moved to DaemonCompiler.
488
+ execute_process (COMMAND "${CMAKE_CXX_COMPILER} " -dumpmachine
489
+ OUTPUT_VARIABLE MACHINE_TRIPLE
490
+ OUTPUT_STRIP_TRAILING_WHITESPACE
491
+ )
492
+
493
+ # If the target architecture has a cross-compiler subfolder, use it.
494
+ if (MACHINE_TRIPLE )
495
+ set (MACHINE_ROOT_PATH "/usr/${MACHINE_TRIPLE} " )
496
+
497
+ if (NOT IS_DIRECTORY "${MACHINE_ROOT_PATH} " )
498
+ unset (MACHINE_ROOT_PATH )
499
+ endif ()
500
+ endif ()
501
+ endif ()
502
+
482
503
# Add to paths
483
- set (CMAKE_FIND_ROOT_PATH ${DEPS_DIR} ${CMAKE_FIND_ROOT_PATH} )
504
+ set (CMAKE_FIND_ROOT_PATH ${DEPS_DIR} ${CMAKE_FIND_ROOT_PATH} ${MACHINE_ROOT_PATH} )
484
505
set (CMAKE_INCLUDE_PATH ${DEPS_DIR} ${DEPS_DIR} /include ${CMAKE_INCLUDE_PATH} )
485
506
set (CMAKE_FRAMEWORK_PATH ${DEPS_DIR} ${CMAKE_FRAMEWORK_PATH} )
486
507
set (CMAKE_PREFIX_PATH ${DEPS_DIR} ${CMAKE_PREFIX_PATH} )
508
+
487
509
if (DAEMON_PARENT_SCOPE_DIR )
488
510
# Also set parent scope so the top level CMakeLists can find precompiled deps
489
511
set (CMAKE_FIND_ROOT_PATH ${DEPS_DIR} ${CMAKE_FIND_ROOT_PATH} PARENT_SCOPE )
You can’t perform that action at this time.
0 commit comments