[cmake-developers] [CMake 0014359]: [FindSWIG] SWIG detection fails when cross-compiling
Mantis Bug Tracker
mantis at public.kitware.com
Wed Aug 14 18:49:21 EDT 2013
The following issue has been SUBMITTED.
======================================================================
http://public.kitware.com/Bug/view.php?id=14359
======================================================================
Reported By: Michel Zou
Assigned To:
======================================================================
Project: CMake
Issue ID: 14359
Category: Modules
Reproducibility: always
Severity: minor
Priority: normal
Status: new
======================================================================
Date Submitted: 2013-08-14 18:49 EDT
Last Modified: 2013-08-14 18:49 EDT
======================================================================
Summary: [FindSWIG] SWIG detection fails when cross-compiling
Description:
The detection of swig fails when cross-compiling, here's why:
When cross-compiling, we do not want find_path to find files in the host tree,
so we set the root path to the target libs and includes:
set ( CMAKE_FIND_ROOT_PATH /usr/i386-mingw32 )
set ( CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY )
but we never want cmake to find utils (like swig, awk, bc, etc...) in the target
tree but in the host prefix:
set ( CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER )
Swig uses 'swig -swiglib' to determine the location of it's internal library:
execute_process(COMMAND ${SWIG_EXECUTABLE} -swiglib
OUTPUT_VARIABLE SWIG_swiglib_output)
Then it uses find-path to check the library macros presence:
find_path(SWIG_DIR swig.swg PATHS ${SWIG_swiglib_output})
But with CMAKE_FIND_ROOT_PATH_MODE_INCLUDE set to ONLY, the path cannot be found
in the host paths, and the required SWIG_DIR is not found ; the detection fails:
-- Could NOT find SWIG (missing: SWIG_DIR)
Steps to Reproduce:
Try to find swig while crosscompiling:
- in CMakeLists:
find_package(SWIG)
- in ToolChain-i386-mingw32:
set ( CMAKE_SYSTEM_NAME Windows )
set ( CMAKE_C_COMPILER i386-mingw32-gcc )
set ( CMAKE_FIND_ROOT_PATH /usr/i386-mingw32 )
set ( CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER )
set ( CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY )
set ( CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY )
Additional Information:
We could also search in the host paths by passing CMAKE_FIND_ROOT_PATH_BOTH to
find_file:
find_path(SWIG_DIR swig.swg PATHS ${SWIG_swiglib_output}
CMAKE_FIND_ROOT_PATH_BOTH)
See the embedded path, tested with and without cross-compilation.
Regards,
M.
======================================================================
Issue History
Date Modified Username Field Change
======================================================================
2013-08-14 18:49 Michel Zou New Issue
2013-08-14 18:49 Michel Zou File Added: cmake-swig-cross-compilation.patch
======================================================================
More information about the cmake-developers
mailing list