MantisBT - CMake
View Issue Details
0009656CMakeCMakepublic2009-10-04 12:262009-10-05 11:48
Modestas Vainius 
Brad King 
normalminoralways
closedfixed 
CMake-2-8 
 
0009656: Enabling C adds duplicates in CMAKE_SYSTEM_{PREFIX,INCLUDE}_PATH
Contents of CMAKE_SYSTEM_{PREFIX,INCLUDE}_PATH are duplicated if more than one language is enabled. This is probably because Modules/Platform/UnixPaths.cmake gets reincluded for each language.

CMake 2.8-rc2 on Debian GNU/Linux
One language
------------
project(testproject C)
cmake_minimum_required(VERSION 2.6)
FOREACH(var ${CMAKE_SYSTEM_PREFIX_PATH})
    MESSAGE(STATUS "CMAKE_SYSTEM_PREFIX_PATH = " ${var})
ENDFOREACH(var)
MESSAGE(STATUS)
FOREACH(var ${CMAKE_SYSTEM_INCLUDE_PATH})
    MESSAGE(STATUS "CMAKE_SYSTEM_INCLUDE_PATH = " ${var})
ENDFOREACH(var)

$ rm -f CMakeCache.txt ; cmake .
-- The C compiler identification is GNU
-- Check for working C compiler: /mnt/sda2/usr/bin/gcc
-- Check for working C compiler: /mnt/sda2/usr/bin/gcc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- CMAKE_SYSTEM_PREFIX_PATH = /
-- CMAKE_SYSTEM_PREFIX_PATH = /usr
-- CMAKE_SYSTEM_PREFIX_PATH = /usr/local
-- CMAKE_SYSTEM_PREFIX_PATH = /mnt/sda2/usr
-- CMAKE_SYSTEM_PREFIX_PATH = /usr/local
-- CMAKE_SYSTEM_PREFIX_PATH = /
-- CMAKE_SYSTEM_PREFIX_PATH = /usr
-- CMAKE_SYSTEM_PREFIX_PATH = /usr/local
-- CMAKE_SYSTEM_PREFIX_PATH = /mnt/sda2/usr
-- CMAKE_SYSTEM_PREFIX_PATH = /usr/local
--
-- CMAKE_SYSTEM_INCLUDE_PATH = /usr/include/w32api
-- CMAKE_SYSTEM_INCLUDE_PATH = /usr/X11R6/include
-- CMAKE_SYSTEM_INCLUDE_PATH = /usr/include/X11
-- CMAKE_SYSTEM_INCLUDE_PATH = /opt/local/include
-- CMAKE_SYSTEM_INCLUDE_PATH = /usr/pkg/include
-- CMAKE_SYSTEM_INCLUDE_PATH = /opt/csw/include
-- CMAKE_SYSTEM_INCLUDE_PATH = /opt/include
-- CMAKE_SYSTEM_INCLUDE_PATH = /usr/openwin/include
-- CMAKE_SYSTEM_INCLUDE_PATH = /usr/include/w32api
-- CMAKE_SYSTEM_INCLUDE_PATH = /usr/X11R6/include
-- CMAKE_SYSTEM_INCLUDE_PATH = /usr/include/X11
-- CMAKE_SYSTEM_INCLUDE_PATH = /opt/local/include
-- CMAKE_SYSTEM_INCLUDE_PATH = /usr/pkg/include
-- CMAKE_SYSTEM_INCLUDE_PATH = /opt/csw/include
-- CMAKE_SYSTEM_INCLUDE_PATH = /opt/include
-- CMAKE_SYSTEM_INCLUDE_PATH = /usr/openwin/include
-- Configuring done
-- Generating done
-- Build files have been written to: /home/modax/test


Two languages
-------------
project(testproject C CXX)
cmake_minimum_required(VERSION 2.6)
FOREACH(var ${CMAKE_SYSTEM_PREFIX_PATH})
    MESSAGE(STATUS "CMAKE_SYSTEM_PREFIX_PATH = " ${var})
ENDFOREACH(var)
MESSAGE(STATUS)
FOREACH(var ${CMAKE_SYSTEM_INCLUDE_PATH})
    MESSAGE(STATUS "CMAKE_SYSTEM_INCLUDE_PATH = " ${var})
ENDFOREACH(var)

$ rm -f CMakeCache.txt ; cmake .
-- The C compiler identification is GNU
-- The CXX compiler identification is GNU
-- Check for working C compiler: /mnt/sda2/usr/bin/gcc
-- Check for working C compiler: /mnt/sda2/usr/bin/gcc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /mnt/sda2/usr/bin/c++
-- Check for working CXX compiler: /mnt/sda2/usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- CMAKE_SYSTEM_PREFIX_PATH = /
-- CMAKE_SYSTEM_PREFIX_PATH = /usr
-- CMAKE_SYSTEM_PREFIX_PATH = /usr/local
-- CMAKE_SYSTEM_PREFIX_PATH = /mnt/sda2/usr
-- CMAKE_SYSTEM_PREFIX_PATH = /usr/local
-- CMAKE_SYSTEM_PREFIX_PATH = /
-- CMAKE_SYSTEM_PREFIX_PATH = /usr
-- CMAKE_SYSTEM_PREFIX_PATH = /usr/local
-- CMAKE_SYSTEM_PREFIX_PATH = /mnt/sda2/usr
-- CMAKE_SYSTEM_PREFIX_PATH = /usr/local
--
-- CMAKE_SYSTEM_INCLUDE_PATH = /usr/include/w32api
-- CMAKE_SYSTEM_INCLUDE_PATH = /usr/X11R6/include
-- CMAKE_SYSTEM_INCLUDE_PATH = /usr/include/X11
-- CMAKE_SYSTEM_INCLUDE_PATH = /opt/local/include
-- CMAKE_SYSTEM_INCLUDE_PATH = /usr/pkg/include
-- CMAKE_SYSTEM_INCLUDE_PATH = /opt/csw/include
-- CMAKE_SYSTEM_INCLUDE_PATH = /opt/include
-- CMAKE_SYSTEM_INCLUDE_PATH = /usr/openwin/include
-- CMAKE_SYSTEM_INCLUDE_PATH = /usr/include/w32api
-- CMAKE_SYSTEM_INCLUDE_PATH = /usr/X11R6/include
-- CMAKE_SYSTEM_INCLUDE_PATH = /usr/include/X11
-- CMAKE_SYSTEM_INCLUDE_PATH = /opt/local/include
-- CMAKE_SYSTEM_INCLUDE_PATH = /usr/pkg/include
-- CMAKE_SYSTEM_INCLUDE_PATH = /opt/csw/include
-- CMAKE_SYSTEM_INCLUDE_PATH = /opt/include
-- CMAKE_SYSTEM_INCLUDE_PATH = /usr/openwin/include
-- Configuring done
-- Generating done
-- Build files have been written to: /home/modax/test
No tags attached.
related to 0004772closed Bill Hoffman CMAKE_BUILD_TYPE does not work correctly for language enabled with ENABLE_LANGUAGE 
Issue History
2009-10-04 12:26Modestas VainiusNew Issue
2009-10-04 15:18Bill HoffmanStatusnew => assigned
2009-10-04 15:18Bill HoffmanAssigned To => Brad King
2009-10-04 15:28Modestas VainiusNote Added: 0017938
2009-10-05 11:22Brad KingRelationship addedrelated to 0004772
2009-10-05 11:28Brad KingNote Added: 0017948
2009-10-05 11:30Brad KingNote Added: 0017949
2009-10-05 11:30Brad KingSummaryThe more languages are enabled the more dupes in CMAKE_SYSTEM_{PREFIX,INCLUDE}_PATH => Enabling C adds duplicates in CMAKE_SYSTEM_{PREFIX,INCLUDE}_PATH
2009-10-05 11:48Brad KingNote Added: 0017951
2009-10-05 11:48Brad KingStatusassigned => closed
2009-10-05 11:48Brad KingResolutionopen => fixed

Notes
(0017938)
Modestas Vainius   
2009-10-04 15:28   
Sorry, as you see, if project(testproject C), they are still duplicated. However, if only CXX, then not:

project(testproject CXX)
cmake_minimum_required(VERSION 2.6)
FOREACH(var ${CMAKE_SYSTEM_PREFIX_PATH})
    MESSAGE(STATUS "CMAKE_SYSTEM_PREFIX_PATH = " ${var})
ENDFOREACH(var)
MESSAGE(STATUS)
FOREACH(var ${CMAKE_SYSTEM_INCLUDE_PATH})
    MESSAGE(STATUS "CMAKE_SYSTEM_INCLUDE_PATH = " ${var})
ENDFOREACH(var)

$ rm -f CMakeCache.txt ; cmake .
-- The CXX compiler identification is GNU
-- Check for working CXX compiler: /mnt/sda2/usr/bin/c++
-- Check for working CXX compiler: /mnt/sda2/usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- CMAKE_SYSTEM_PREFIX_PATH = /
-- CMAKE_SYSTEM_PREFIX_PATH = /usr
-- CMAKE_SYSTEM_PREFIX_PATH = /usr/local
-- CMAKE_SYSTEM_PREFIX_PATH = /mnt/sda2/usr
-- CMAKE_SYSTEM_PREFIX_PATH = /usr/local
--
-- CMAKE_SYSTEM_INCLUDE_PATH = /usr/include/w32api
-- CMAKE_SYSTEM_INCLUDE_PATH = /usr/X11R6/include
-- CMAKE_SYSTEM_INCLUDE_PATH = /usr/include/X11
-- CMAKE_SYSTEM_INCLUDE_PATH = /opt/local/include
-- CMAKE_SYSTEM_INCLUDE_PATH = /usr/pkg/include
-- CMAKE_SYSTEM_INCLUDE_PATH = /opt/csw/include
-- CMAKE_SYSTEM_INCLUDE_PATH = /opt/include
-- CMAKE_SYSTEM_INCLUDE_PATH = /usr/openwin/include
-- Configuring done
-- Generating done
-- Build files have been written to: /home/modax/test
(0017948)
Brad King   
2009-10-05 11:28   
The fix for issue 0004772 caused this. It taught CMakeCInformation.cmake (but not CMakeCXXInformation or CMakeFortranInformation) to include the system info file again (e.g. Linux.cmake). The change was a quick-fix, as seen by this comment it added:

+# some systems include the compiler information in the system file
+# and if this is the enable_language command then it may not have been
+# included at this point, or needs to be included again so that the
+# language_INIT variables are set correctly

The real fix is to factor out all the compiler-specific information into the new-style platform modules of the form

  Compiler/<id>-<lang>.cmake
  Platform/<os>-<id>-<lang>.cmake

so that the system info file does not need to be included multiple times.

This was already done for some compilers but not all compilers.
(0017949)
Brad King   
2009-10-05 11:30   
I'm changing the title of this issue from

  "The more languages are enabled the more dupes in CMAKE_SYSTEM_{PREFIX,INCLUDE}_PATH"

to

  "Enabling C adds duplicates in CMAKE_SYSTEM_{PREFIX,INCLUDE}_PATH"

because it does not happen for other languages. Currently the paths are listed at most twice.
(0017951)
Brad King   
2009-10-05 11:48   
Until the full refactoring of compiler information is done, we can address this bug by adding include blockers to UnixPaths.cmake and WindowsPaths.cmake:

Avoid (Unix|Windows)Paths.cmake multiple include
/cvsroot/CMake/CMake/Modules/Platform/UnixPaths.cmake,v <-- Modules/Platform/UnixPaths.cmake
new revision: 1.17; previous revision: 1.16
/cvsroot/CMake/CMake/Modules/Platform/WindowsPaths.cmake,v <-- Modules/Platform/WindowsPaths.cmake
new revision: 1.8; previous revision: 1.7