[CMake] CMAKE_CACHE_MAJOR_VERSION not set yet during initial cmake run

Mike Jackson mike.jackson at imts.us
Fri Jul 11 11:27:14 EDT 2008


I think what you want is:


CMAKE_MAJOR_VERSION and

CMAKE_MINOR_VERSION


--  
Mike Jackson   Senior Research Engineer
Innovative Management & Technology Services


On Jul 11, 2008, at 11:03 AM, Wheeler, Frederick W (GE, Research) wrote:

>
> I'm trying to use CMAKE_CACHE_MAJOR_VERSION and
> CMAKE_CACHE_MINOR_VERSION to determine which version of cmake is being
> used, but it seems that these vars are not yet set during the first
> cmake run.  This is demonstrated in a simple test case below.   
> CMake is
> run twice, and you can see in the 'debug' prints are different on the
> second cmake run.
>
> Is there a better way to determine the cmake version being used?
>
> Thanks,
> Fred
>
>
> 0% cat CMakeLists.txt
> SET( VER "${CMAKE_CACHE_MAJOR_VERSION}.${CMAKE_CACHE_MINOR_VERSION}" )
> MESSAGE("debug ${VER}")
> IF( "${VER}" STRGREATER "2.5" )
>   MESSAGE("debug NEW CMAKE")
> ELSE( "${VER}" STRGREATER "2.5" )
>   MESSAGE("debug OLD CMAKE")
> ENDIF( "${VER}" STRGREATER "2.5" )
>
> 0% cmake --version
> cmake version 2.6-patch 0
>
> 0% ls
> CMakeLists.txt
>
> 0% cmake .
> -- The C compiler identification is GNU
> -- The CXX compiler identification is GNU
> -- Check for working C compiler: /usr/bin/gcc.exe
> -- Check for working C compiler: /usr/bin/gcc.exe -- works
> -- Detecting C compiler ABI info
> -- Detecting C compiler ABI info - done
> -- Check for working CXX compiler: /usr/bin/c++.exe
> -- Check for working CXX compiler: /usr/bin/c++.exe -- works
> -- Detecting CXX compiler ABI info
> -- Detecting CXX compiler ABI info - done
> debug .
> debug OLD CMAKE
> -- Configuring done
> -- Generating done
> -- Build files have been written to: /cygdrive/d/home/wheeler/tmp_ver
>
> 0% cmake .
> debug 2.6
> debug NEW CMAKE
> -- Configuring done
> -- Generating done
> -- Build files have been written to: /cygdrive/d/home/wheeler/tmp_ver
>
> _______________________________________________
> CMake mailing list
> CMake at cmake.org
> http://www.cmake.org/mailman/listinfo/cmake
>




More information about the CMake mailing list