[CMake] skip repeated compiler id checks
Daniel Pfeifer
daniel at pfeifer-mail.de
Thu Jan 27 12:10:57 EST 2011
Hi,
In order to support testcases that check whether a source file
successfully compiles, links or runs, I am creating a CMakeLists.txt
file with the following content:
> cmake_minimum_required(VERSION 2.8)
> project(compile_link_run_test)
> add_library(compile STATIC ${sources})
> add_executable(link ${sources})
> add_custom_target(run COMMAND link)
Then I add the test like this (${target} is one of compile, link, run):
> add_test(${name}
> ${CMAKE_CTEST_COMMAND}
> --build-and-test ${directory} ${directory}
> --build-generator ${CMAKE_GENERATOR}
> --build-makeprogram ${CMAKE_MAKE_PROGRAM}
> --build-target "${target}"
> --build-options
> "-DCMAKE_CXX_COMPILER:FILEPATH=${CMAKE_CXX_COMPILER}"
> "-DCMAKE_C_COMPILER:FILEPATH=${CMAKE_C_COMPILER}"
> "-DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE}"
> )
This works, but it takes heaps of time because for every testcase CMake
does the same checks whether the compiler works. Is there a way to reuse
this information from the CMake process that creates the testcases?
The 'try_compile' function works in a similar way but does not suffer
from this problem. How is it handled there?
cheers, Daniel
More information about the CMake
mailing list