CMAKE_COMPILER_IS_GNUCXX and CMAKE_CXX_COMPILER_ID are empty

后端 未结 2 1464
感动是毒
感动是毒 2021-02-14 08:49

I am currently playing around with CMake and want to detect the compiler and the compiler version. My current CMakeLists.txt looks as follows:

cmake         


        
2条回答
  •  我寻月下人不归
    2021-02-14 09:21

    Place it after project command:

    > cat CMakeLists.txt 
    cmake_minimum_required(VERSION 2.8)
    
    message("before:")
    message(">    ${CMAKE_CXX_COMPILER}")
    message(">    ${CMAKE_CXX_COMPILER_ID}")
    message(">    ${CMAKE_COMPILER_IS_GNUCXX}")
    message("-----------------")
    
    project(Foo)
    
    message("after:")
    message(">    ${CMAKE_CXX_COMPILER}")
    message(">    ${CMAKE_CXX_COMPILER_ID}")
    message(">    ${CMAKE_COMPILER_IS_GNUCXX}")
    message("-----------------")
    
    > cmake -H. -B_builds
    before:
    >    
    >    
    >    
    -----------------
    -- The C compiler identification is GNU 4.8.1
    -- The CXX compiler identification is GNU 4.8.1
    -- Check for working C compiler: /usr/bin/cc
    -- Check for working C compiler: /usr/bin/cc -- works
    -- Detecting C compiler ABI info
    -- Detecting C compiler ABI info - done
    -- Check for working CXX compiler: /usr/bin/c++
    -- Check for working CXX compiler: /usr/bin/c++ -- works
    -- Detecting CXX compiler ABI info
    -- Detecting CXX compiler ABI info - done
    after:
    >    /usr/bin/c++
    >    GNU
    >    1
    -----------------
    -- Configuring done
    -- Generating done
    -- Build files have been written to: /.../_builds
    

提交回复
热议问题