2020年10月7日 星期三

[CMake] FAQ

  • Build Type
    • cmake -DCMAKE_BUILD_TYPE=Debug/Release ..
       
  • Dump all variables
      function(dump_cmake_variables)
        get_cmake_property(_variableNames VARIABLES)
        list (SORT _variableNames)
        foreach (_variableName ${_variableNames})
            if (ARGV0)
                unset(MATCHED)
                string(REGEX MATCH ${ARGV0} MATCHED ${_variableName})
                if (NOT MATCHED)
                    continue()
                endif()
            endif()
            message(STATUS "${_variableName}=${${_variableName}}")
        endforeach()
    endfunction()
      
  • Q: 加了 link_directories, link 時仍找不到 library
  • Q: How to enable C++11?
    • set(CMAKE_CXX_STANDARD 11)
      set(CMAKE_CXX_STANDARD_REQUIRED ON)
      
    • 或是
      ADD_DEFINITIONS(
          -std=c++11 # or -std=c++0x
      )
      

沒有留言:

張貼留言