View Issue Details Jump to Notes ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0015358CMakeCMakepublic2015-01-18 14:092015-09-29 09:13
ReporterAlexey Chernov 
Assigned ToBrad King 
PrioritynormalSeveritytextReproducibilityalways
StatusclosedResolutionfixed 
PlatformOSOS Version
Product VersionCMake 3.1 
Target VersionFixed in VersionCMake 3.2 
Summary0015358: Clarify try_compile and try_run documentation
Descriptiontry_compile command apparently ignores INCLUDE_DIRECTORIES argument for unknown reason. As documentation (http://www.cmake.org/cmake/help/v3.1/command/try_compile.html [^]) reads:
"Some extra flags that can be included are, INCLUDE_DIRECTORIES, LINK_DIRECTORIES, and LINK_LIBRARIES. COMPILE_DEFINITIONS are -Ddefinition that will be passed to the compile line." But unfortunately parameter of INCLUDE_DIRECTORIES argument won't be transferred to CMakeLists.txt.

It also be true for other arguments mentioned in that paragraph.
Steps To Reproduce1. Write try_compile() command with INCLUDE_DIRECTORIES, e.g.:
try_compile(
    COMPILE_RESULT
    ${CMAKE_BINARY_DIR}
    test.cpp
    INCLUDE_DIRECTORIES ${CMAKE_SOURCE_DIR}/include
    OUTPUT_VARIABLE COMPILE_LOG
)
2. Notice that INCLUDE_DIRECTORIES parameter isn't transferred neither to temporary CMakeLists.txt in CMakeFiles/CMakeTmp (with --debug-trycompile enabled) nor to compiler command line arguments.
TagsNo tags attached.
Attached Files

 Relationships

  Notes
(0037736)
Brad King (manager)
2015-01-19 10:14

There is no such INCLUDE_DIRECTORIES option listed in the signature. The "extra flags" is referring to the CMAKE_FLAGS argument, to which you can give "-DINCLUDE_DIRECTORIES=/dir/a/include;/dir/b/include" to get custom include directories.

The documentation needs to be revised and clarified.
(0037738)
Alexey Chernov (reporter)
2015-01-19 10:25

Thanks for clarification of this.
So, is it right that all these three options (INCLUDE_DIRECTORIES, LINK_DIRECTORIES and LINK_LIBRARIES) are meant to be used with CMAKE_FLAGS, but LINK_LIBRARIES can be also used separately as try_compile() argument?

Generally yes, I agree that it's apparently documentation issue and not a bug.
(0037739)
Brad King (manager)
2015-01-19 10:28

Re 0015358:0037738: Originally all three of those were meant only for use with -D but then the LINK_LIBRARIES option was added as an explicit argument in order to cleanly perform translation of imported targets. If LINK_LIBRARIES is an argument then it no longer works as a -D flag. The documentation is out of date on that I think.
(0037740)
Alexey Chernov (reporter)
2015-01-19 10:33

Thanks again for detailed information. Now it's completely clear for me.
(0037916)
Brad King (manager)
2015-02-04 16:08

I've revised the documentation:

 Help: Revise try_compile and try_run documentation
 http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=219797e4 [^]
(0039037)
Robert Maynard (manager)
2015-07-08 08:57

Closing resolved issues that have not been updated in more than 4 months.

 Issue History
Date Modified Username Field Change
2015-01-18 14:09 Alexey Chernov New Issue
2015-01-19 10:14 Brad King Note Added: 0037736
2015-01-19 10:25 Alexey Chernov Note Added: 0037738
2015-01-19 10:28 Brad King Note Added: 0037739
2015-01-19 10:33 Alexey Chernov Note Added: 0037740
2015-02-04 16:08 Brad King Note Added: 0037916
2015-02-04 16:09 Brad King Assigned To => Brad King
2015-02-04 16:09 Brad King Severity major => text
2015-02-04 16:09 Brad King Status new => resolved
2015-02-04 16:09 Brad King Resolution open => fixed
2015-02-04 16:09 Brad King Fixed in Version => CMake 3.2
2015-02-04 16:09 Brad King Summary try_compile ignores INCLUDE_DIRECTORIES argument => Clarify try_compile and try_run documentation
2015-07-08 08:57 Robert Maynard Note Added: 0039037
2015-07-08 08:57 Robert Maynard Status resolved => closed


Copyright © 2000 - 2018 MantisBT Team