MantisBT - CMake
View Issue Details
0013173CMakeCMakepublic2012-04-27 04:332014-06-02 08:37
Galeazzi 
jschueller 
normalminoralways
closedfixed 
Windows
CMake 2.8.8 
CMake 3.0 
0013173: Swig module can't handle absolute path
When you have an out-of-source project like the following structure:
C:\MyFolder\CMakeList.txt
D:\SourceFolder\wrapper.i
it generates this error:
CMake Error in CMakeLists.txt:
  Cannot find source file:
C:/MyFolder/D:/SourceFolder/wrapper.i
No tags attached.
related to 0013772closed jschueller UseSWIG.cmake does not handle relative paths with parent directories 
has duplicate 0014459closed jschueller SWIG_ADD_MODULE does not create sub directory 
Issue History
2012-04-27 04:33GaleazziNew Issue
2012-04-27 05:01Rolf Eike BeerNote Added: 0029353
2012-04-27 05:21GaleazziNote Added: 0029356
2012-04-27 06:46Rolf Eike BeerNote Added: 0029357
2012-04-27 06:46Rolf Eike BeerAssigned To => Mathieu Malaterre
2012-04-27 06:46Rolf Eike BeerStatusnew => assigned
2013-11-25 08:28Brad KingAssigned ToMathieu Malaterre => jschueller
2013-11-25 08:28Brad KingRelationship addedrelated to 0013772
2013-11-25 08:28Brad KingRelationship addedrelated to 0014459
2013-11-25 09:08jschuellerNote Added: 0034546
2013-11-25 09:08jschuellerStatusassigned => resolved
2013-11-25 09:08jschuellerFixed in Version => CMake 3.0
2013-11-25 09:08jschuellerResolutionopen => fixed
2013-11-25 09:11jschuellerRelationship replacedhas duplicate 0014459
2014-06-02 08:37Robert MaynardNote Added: 0036027
2014-06-02 08:37Robert MaynardStatusresolved => closed

Notes
(0029353)
Rolf Eike Beer   
2012-04-27 05:01   
Please also provide a stripped down version of your CMakeLists.txt.
(0029356)
Galeazzi   
2012-04-27 05:21   
project (MyProject)
  set(SourcesList D:/SourceFolder/wrapper.i
                  D:/SourceFolder/example.cpp
          D:/SourceFolder/example.h
                  D:/SourceFolder/DLLMacros.h
                 )
  include_directories(C:/Tools/Libs
                      C:/Include)
  set(COMPILE_DEF DLLEXPORT;__TOOLS__)
  
  #SWIG Section
  FIND_PACKAGE(SWIG REQUIRED)
  INCLUDE(${SWIG_USE_FILE})

  SET(CMAKE_SWIG_FLAGS "")

  SET_SOURCE_FILES_PROPERTIES(D:/SourceFolder/wrapper.i PROPERTIES CPLUSPLUS ON)
  SWIG_ADD_MODULE(MyProject csharp ${SourcesList})
  
  set_property(TARGET MyProject APPEND PROPERTY COMPILE_DEFINITIONS ${COMPILE_DEF} )
(0029357)
Rolf Eike Beer   
2012-04-27 06:46   
Thank you.

AFAICS this happens because of the fiddling with the source and binary paths in SWIG_ADD_SOURCE_TO_MODULE. I don't understand what is happening there and why it doesn't just use get_filename_component(ABSOLUTE).

As a workaround you could put the source file as a relative path to your source dir into the CMakeLists.txt, that should work for the moment.
(0034546)
jschueller   
2013-11-25 09:08   
http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=276e3735 [^]
(0036027)
Robert Maynard   
2014-06-02 08:37   
Closing resolved issues that have not been updated in more than 4 months.