Skip to content
This repository was archived by the owner on Jun 30, 2025. It is now read-only.
This repository was archived by the owner on Jun 30, 2025. It is now read-only.

try_compile in DetermineGflagsNamespace generates invalid compile command #193

@ambasta

Description

@ambasta

Hi,

Currently try_compile is specified as..

try_compile (${VARIABLE}
        "${CMAKE_BINARY_DIR}" "${_check_file}"
        COMPILE_DEFINITIONS "${CMAKE_REQUIRED_DEFINITIONS}" -DGFLAGS_NAMESPACE=${_namespace}
        LINK_LIBRARIES "${gflags_LIBRARIES}"
        CMAKE_FLAGS -DINCLUDE_DIRECTORIES:STRING="${gflags_INCLUDE_DIR}"
        OUTPUT_VARIABLE OUTPUT)

However, when ${CMAKE_BINARY_DIR} is set to /home/amitprakash/CLionProjects/or-tools/cmake-build-manual/glog_project/src/glog and ${gflags_INCLUDE_DIR} is set to /home/amitprakash/CLionProjects/or-tools/cmake-build-manual/gflags_project/src/gflags/include, the build command generated by try_compile is ..

/usr/bin/c++ -DGFLAGS_NAMESPACE=google -I/home/amitprakash/CLionProjects/or-tools/cmake-build-manual/glog_project/src/glog/CMakeFiles/CMakeTmp/\"/home/amitprakash/CLionProjects/or-tools/cmake-build-manual/gflags_project/src/gflags/include\" -fPIE -o CMakeFiles/cmTC_6795b.dir/DetermineGflagsNamespace.cxx.o -c /home/amitprakash/CLionProjects/or-tools/cmake-build-manual/glog_project/src/glog/CMakeFiles/CMakeTmp/DetermineGflagsNamespace.cxx

I'm unsure why, but the include dir has changed from an ABSPATH to a RELPATH of the form ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/${gflags_INCLUDE_DIR}

The same happens when glog is installed to /usr/include, but the try_compile succeeds anyways, since /usr/include is part of system include dirs

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions