MantisBT - CMake
View Issue Details
0013449CMakeCMakepublic2012-08-01 08:002014-06-02 08:37
Miguel FIGUEIREDO 
jschueller 
normalminoralways
closedfixed 
x86_64linux-3.2.0-27-genericUbuntu 12.04 LTS
CMake 2.8.7 
CMake 3.0 
0013449: [CROSS-CC] FindSWIG.cmake does not work when CMAKE_FIND_ROOT is redefined and CMAKE_FIND_ROOT_PATH_MODE_INCLUDE is set to ONLY
The "FindSWIG.cmake" script internally uses the command FIND_PATH() to set SWIG_DIR variable.

This command may have the path prefix overriden if :
- the variable CMAKE_FIND_ROOT is redefined to point to a different root path than the host machine root path, and
- the variable CMAKE_FIND_ROOT_PATH_MODE_INCLUDE is set to ONLY.

This is a typical use case when building for embedded targets.
- Create a CMakeList.txt which have "find_package(SWIG)" into it (see http://www.cmake.org/Wiki/CMake_FAQ#How_do_I_use_CMake_to_generate_SWIG_wrapper_libraries.3F [^]).

- Create a cmake toolchain script which redefines CMAKE_FIND_ROOT and set CMAKE_FIND_ROOT_PATH_MODE_INCLUDE to only (see http://www.vtk.org/Wiki/CMake_Cross_Compiling#The_toolchain_file [^]).

- Run cmake and make

- The build system should report the following error :
"CMake Error at /usr/share/cmake-2.8/Modules/FindPackageHandleStandardArgs.cmake:91 (MESSAGE):
  Could NOT find SWIG (missing: SWIG_DIR)
Call Stack (most recent call first):
  /usr/share/cmake-2.8/Modules/FindPackageHandleStandardArgs.cmake:252 (_FPHSA_FAILURE_MESSAGE)
  /usr/share/cmake-2.8/Modules/FindSWIG.cmake:74 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
  lw_pvod_core/binding/CMakeLists.txt:1 (find_package)"
I solve the issue by adding the parameter NO_CMAKE_FIND_ROOT_PATH to FIND_PATH() command avoiding path prefix overriding.

--- /usr/share/cmake-2.8/Modules/FindSWIG.cmake 2012-08-01 13:57:45.732656623 +0200
+++ FindSWIG.cmake 2012-08-01 13:57:51.528656642 +0200
@@ -45,7 +45,7 @@
     STRING(REGEX REPLACE "[\n\r]+" ";" SWIG_swiglib_output ${SWIG_swiglib_output})
     # force the path to be computed each time in case SWIG_EXECUTABLE has changed.
     SET(SWIG_DIR SWIG_DIR-NOTFOUND)
- FIND_PATH(SWIG_DIR swig.swg PATHS ${SWIG_swiglib_output})
+ FIND_PATH(SWIG_DIR swig.swg PATHS ${SWIG_swiglib_output} NO_CMAKE_FIND_ROOT_PATH)
     IF(SWIG_DIR)
       SET(SWIG_USE_FILE ${CMAKE_ROOT}/Modules/UseSWIG.cmake)
       EXECUTE_PROCESS(COMMAND ${SWIG_EXECUTABLE} -version
No tags attached.
has duplicate 0014359closed jschueller [FindSWIG] SWIG detection fails when cross-compiling 
Issue History
2012-08-01 08:00Miguel FIGUEIREDONew Issue
2013-10-22 05:25Michel ZouNote Added: 0034213
2013-10-22 05:26Michel ZouNote Edited: 0034213bug_revision_view_page.php?rev_id=1290
2013-11-22 09:08Brad KingAssigned To => jschueller
2013-11-22 09:08Brad KingStatusnew => assigned
2013-11-22 09:14Brad KingNote Added: 0034518
2013-11-22 09:20Brad KingTarget Version => CMake 3.0
2013-11-25 09:03jschuellerNote Deleted: 0034213
2013-11-25 09:04jschuellerNote Added: 0034543
2013-11-25 09:04jschuellerStatusassigned => resolved
2013-11-25 09:04jschuellerResolutionopen => fixed
2013-11-25 09:21jschuellerRelationship addedhas duplicate 0014359
2014-06-02 08:37Robert MaynardNote Added: 0036039
2014-06-02 08:37Robert MaynardStatusresolved => closed

Notes
(0034518)
Brad King   
2013-11-22 09:14   
FindSWIG: Search for swig.swg only on host
http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=19b7a54d [^]
(0034543)
jschueller   
2013-11-25 09:04   
http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=19b7a54d [^]
(0036039)
Robert Maynard   
2014-06-02 08:37   
Closing resolved issues that have not been updated in more than 4 months.