Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

try_compile in DetermineGflagsNamespace generates invalid compile command #193

Closed
ambasta opened this issue Jun 7, 2017 · 4 comments
Closed

Comments

@ambasta
Copy link

ambasta commented Jun 7, 2017

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

@ambasta
Copy link
Author

ambasta commented Jun 7, 2017

Rewriting it 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)

fixes the issue

@sergiud
Copy link
Collaborator

sergiud commented Jul 9, 2017

I don't follow. What's the difference between the two try_compile calls and what part of the original command is invalid?

@ambasta
Copy link
Author

ambasta commented Jul 9, 2017

CMAKE_FLAGS -DINCLUDE_DIRECTORIES:STRING="${gflags_INCLUDE_DIR}"
vs
CMAKE_FLAGS "-DINCLUDE_DIRECTORIES:STRING=${gflags_INCLUDE_DIR}"

The difference is quotations. CMake flags need to be quoted for the command to work correctly

@sergiud
Copy link
Collaborator

sergiud commented Jul 9, 2017

Please give #209 a try and let me if the PR works for you.

@shinh shinh closed this as completed in e50aeaa Jul 9, 2017
shinh added a commit that referenced this issue Jul 9, 2017
cmake: fixed gflags namespace detection (fixes #193)
durswd pushed a commit to durswd/glog that referenced this issue Sep 2, 2019
This commit fixes gflags namespace detection using Intel compiler and ensures
the generated try_compile command line does not produce malformed paths.
durswd pushed a commit to durswd/glog that referenced this issue Sep 2, 2019
cmake: fixed gflags namespace detection (fixes google#193)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants