View Issue Details Jump to Notes ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0014359CMakeModulespublic2013-08-14 18:492014-06-02 08:37
ReporterMichel Zou 
Assigned Tojschueller 
PrioritynormalSeverityminorReproducibilityalways
StatusclosedResolutionduplicate 
PlatformOSOS Version
Product VersionCMake 2.8.11.2 
Target VersionFixed in Version 
Summary0014359: [FindSWIG] SWIG detection fails when cross-compiling
DescriptionThe 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 ReproduceTry 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 InformationWe 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.
TagsNo tags attached.
Attached Filespatch file icon cmake-swig-cross-compilation.patch [^] (683 bytes) 2013-08-14 18:49 [Show Content]

 Relationships
duplicate of 0013449closedjschueller [CROSS-CC] FindSWIG.cmake does not work when CMAKE_FIND_ROOT is redefined and CMAKE_FIND_ROOT_PATH_MODE_INCLUDE is set to ONLY 

  Notes
(0033719)
Michel Zou (reporter)
2013-08-15 07:01

It is all the more blocking since SWIG_DIR is reset each time:
set(SWIG_DIR SWIG_DIR-NOTFOUND)
find_path(SWIG_DIR swig.swg PATHS ${SWIG_swiglib_output})
, and we cannot provide an additional location by passing explicitely the correct location, maybe a HINTS variable could also be passed ?

Moreover SWIG_DIR and SWIG_VERSION should be marked:
mark_as_advanced ( SWIG_VERSION SWIG_DIR )
(0033775)
Michel Zou (reporter)
2013-09-03 05:48

I think it's a duplicate of http://public.kitware.com/Bug/view.php?id=13449 [^]

From a year ago... C'mon guys :!
(0036038)
Robert Maynard (manager)
2014-06-02 08:37

Closing resolved issues that have not been updated in more than 4 months.

 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
2013-08-15 07:01 Michel Zou Note Added: 0033719
2013-09-03 05:48 Michel Zou Note Added: 0033775
2013-11-25 09:21 jschueller Relationship added duplicate of 0013449
2013-11-25 09:21 jschueller Status new => resolved
2013-11-25 09:21 jschueller Resolution open => duplicate
2013-11-25 09:21 jschueller Assigned To => jschueller
2014-06-02 08:37 Robert Maynard Note Added: 0036038
2014-06-02 08:37 Robert Maynard Status resolved => closed


Copyright © 2000 - 2018 MantisBT Team