summaryrefslogtreecommitdiffstats
path: root/Tests/TryCompile
Commit message (Collapse)AuthorAgeFilesLines
* Tests: Fix clang -Wstrict-prototypes warningsBrad King2023-10-267-7/+7
|
* Tests: Bump CMake minimum required in tests to 3.5Brad King2023-03-012-2/+2
| | | | | | | | | | | | | | | | | | | CMake 3.27 deprecates compatibility with CMake < 3.5. Update tests that do not cover older interfaces to avoid the deprecation warning. Follow the pattern from: * commit 7b07ccdd2b (Tests/*Only: Update cmake_minimum_required versions, 2020-06-15, v3.19.0-rc1~629^2~1) * commit 72e7c45e98 (Tests: Bump CMake minimum required in tests to 2.8.12, 2020-12-22, v3.20.0-rc1~224^2) * commit f6b4db365a (Tests: bump cmake_minimum_required version to 2.8.12, 2021-04-04, v3.21.0-rc1~372^2) Also remove explicit `cmake_policy` settings made redundant by the version.
* Tests: Fix TryCompile bad source case for clang-cl 15 on WindowsBrad King2022-11-101-1/+1
| | | | | | When `pass.c bad#source.c` passes through `nmake`, the compiler gets `pass.c bad`. The clang-cl 15 compiler now fails on `bad` with an error that we did not previously match. Update our regex.
* Tests: Move TryCompile check module cases to RunCMake.Check*Brad King2022-10-061-144/+0
| | | | The latter already have similar checks for similar modules.
* try_compile: Rename SOURCE_FROM_ARG -> SOURCE_FROM_CONTENTMatthew Woehlke2022-09-301-5/+5
| | | | | | | | | Change the SOURCE_FROM_ARG keyword to try_compile to SOURCE_FROM_CONTENT (which we can do because it was recently added and hasn't been in a release yet). The new name should be clearer as to what it does, and also more consistent with the CONTENT arguments to some other commands. Also, fix a typo in an error message.
* try_compile: Add NO_CACHE option (also try_run)Matthew Woehlke2022-09-281-0/+52
| | | | | | | Add NO_CACHE option to try_compile and try_run, which places the results in regular, rather than cache, variables. Issue: #22799
* try_compile: Add SOURCE_FROM_FILEMatthew Woehlke2022-09-221-0/+6
| | | | | | | Add ability to copy try_compile (and try_run) source files from arbitrary locations into the operation directory. This is included for the sake of completion and consolidation, although use cases which actually require this may be rare.
* Tests: Clean up and simplify TryCompile testsMatthew Woehlke2022-09-223-46/+29
| | | | | | Add and use some additional helper macros to simplify repetitive checks. Use existing macros in more places. Tweak macros to improve output in case of failure.
* try_compile: Add SOURCE_FROM_{ARG,VAR}Matthew Woehlke2022-09-221-0/+42
| | | | | | | | Add ability to "feed" try_compile (and try_run) sources more directly, either from literal content, or from a CMake variable which contains literal content. This saves the user from needing a separate step to write the content to a file, and allows for the sources to only exist in the scratch directory.
* try_compile: Add PROJECT keyword-dispatched signatureMatthew Woehlke2022-09-141-1/+10
| | | | | | | Introduce a new signature for the project flavor of try_compile (and try_run) which removes the `bindir` argument and adds a required PROJECT tag. This is similar to the SOURCES flavor added by commit aa9220d3 (try_compile: Add keyword-dispatched signature, 2022-09-02).
* try_compile: Add keyword-dispatched signatureMatthew Woehlke2022-09-052-240/+282
| | | | | | | | | | | | | | | | Introduce a new signature for try_compile (and try_run) which removes the `bindir` argument and requires the SOURCES tag. This will eventually allow us to add other ways of providing sources, but also allows us to change the behavior without breaking compatibility. The old signature uses a special, but non-unique temporary location inside the specified `bindir`, which conventionally is just the project's build directory. The new signature unconditionally uses the a unique temporary directory which is unconditionally within the project's build directory (which is no longer separately specified). This ensures that successive runs do not overwrite previous runs, will simplify debugging, and should also, eventually, allow us to execute multiple trials in parallel.
* try_compile: Clean up testsMatthew Woehlke2022-08-181-36/+10
| | | | | | Switch order of one try_compile test so that the total set of tests is in a more sensible order. Remove two duplicate tests. Remove some gratuitous (and not entirely accurate) messages.
* try_run: Add RUN_OUTPUT_STDOUT_VARIABLE and RUN_OUTPUT_STDERR_VARIABLE.Patrick Northon2022-07-082-1/+30
|
* messages: remove screamake from comments and errorsBen Boeckel2022-04-251-1/+1
|
* Tests: Use idiomatic try_compile calls in TryCompile testBrad King2022-02-162-18/+18
| | | | | Do not duplicate the `CMakeFiles/CMakeTmp` portion of the path. The `try_compile` command adds that automatically.
* LCC: Add policy CMP0129 regarding interpreting LCC as GNUmakise-homura2021-10-211-0/+3
| | | | | | | | | | Due to MCST LCC compiler identification is now changed to LCC, there should be a way for old projects to still identify it as GNU, as it was before. This commits adds the policy: CMP0129: Compiler id for MCST LCC compilers is now LCC, not GNU. This policy controls such a behavior. OLD behaivior is to treat LCC as GNU, NEW is to treat is as LCC.
* LCC: Add dedicated support for MCST LCC compilermakise-homura2021-10-151-1/+1
| | | | | | | | | | | | | | | | | | | | | Divert LCC compiler as a new one, instead of treating it as GNU. Since old times, Elbrus C/C++/Fortran Compiler (LCC) by MCST has been passing checks for GNU compilers, so it has been identified as GNU. Now, with intent of seriously upstreaming its support, it has been added as a separate LCC compiler, and its version displays not a supported GCC version, but LCC version itself (e.g. LCC 1.25.19 instead of GNU 7.3.0). This commit adds its support for detection, and also converts basically every check like 'is this compiler GNU?' to 'is this compiler GNU or LCC?'. The only places where this check is untouched, is where it regards other platforms where LCC is unavailable (primarily non-Linux), and where it REALLY differs from GNU compiler. Note: this transition may break software that are already ported to Elbrus, but hardly relies that LCC will be detected as GNU; still such software is not known.
* Merge topic 'check_cxx_compiler_flag_no_normal_variable'Brad King2021-07-081-0/+10
|\ | | | | | | | | | | | | 018d300ca0 Check*CompilerFlag: Do not set result as a normal variable too Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !6318
| * Check*CompilerFlag: Do not set result as a normal variable tooRobert Maynard2021-07-081-0/+10
| | | | | | | | | | | | | | | | | | | | | | This was previously fixed by commit d46590910c (Check*CompilerFlag: Do not set result as a normal variable too, 2020-09-21, v3.18.3~1^2^2), but was regressed by refactoring in commit 90dead024c (CheckCompilerFlag: unified way to check compiler flags per language, 2020-09-25, v3.19.0-rc1~88^2) due to the changes being developed concurrently. Fix it again, and add a test case. Fixes: #21207
* | Tests: bump cmake_minimum_required version to 2.8.12Rolf Eike Beer2021-04-052-2/+2
|/ | | | | This needlessly produces warnings during the test runs that no-one sees but that are distracting when actually inspecting the logs.
* Add a test to verify '\' handling in CHECK_CXX_SOURCE_COMPILESRobert Maynard2020-09-231-0/+4
|
* Makefiles: Do not use '\#' escape sequence with Windows-style make toolsBrad King2020-04-151-1/+1
| | | | | | | | | | | Since commit fbf7a92975 (Makefile: Handle '#' in COMPILE_OPTIONS, 2014-08-12, v3.1.0-rc1~174^2) we escape `#` as `\#` in `flags.make` variable assignments so that they are not treated as a comment. Windows-style make tools like NMake do not interpret backslashes in that way. Other means will be needed to handle `#` in contexts where it is even possible. The test suite is not covering this for NMake anyway, and actually has a workaround in `Tests/TryCompile` for the old behavior, which we can now update.
* ObjC: Add try_compile supportCristian Adam2019-11-093-0/+24
| | | | Fixes: #19920
* Languages: Add support for Objective-C++Steve Wilson2019-09-281-20/+46
| | | | | | | | | | | | | | | | | Add entries in Modules and Modules/Platform to support Objective-C++ compiler determination and identification. Add Modules to check Objective-C++ compiler flags, source compilations, program checks, etc... Use OBJCXX as the designator of the language, eg: project(foo OBJCXX) Add various tests for Objective-C++ language features. Add tests to preserve C++ handling of .M and .mm files when Objective-C++ is not a configured language. Co-authored-by: Cristian Adam <cristian.adam@gmail.com>
* Languages: Add support for Objective-CSteve Wilson2019-09-281-1/+29
| | | | | | | | | | | | | | | | | Add entries in Modules and Modules/Platform to support Objective-C compiler determination and identification. Add Modules to check Objective-C compiler flags, source compilations, program checks, etc... Use OBJC as the designator of the language, eg: project(foo OBJC) Add various tests for Objective-C language features. Add tests to preserve C++ handling of .m and .mm files when OBJC is not a configured language. Co-Authored-By: Cristian Adam <cristian.adam@gmail.com>
* try_compile: Restore expansion of ;-list in COMPILE_DEFINITIONSBrad King2019-02-152-0/+39
| | | | | | | | | | | | | | | | | | | | | The quoting added by commit 8c5221fb1f (try_compile: Preserve special characters in COMPILE_DEFINITIONS, 2019-01-21, v3.14.0-rc1~108^2~3) broke the case that the `COMPILE_DEFINITIONS` value contains a `;`. Without the quoting the `;` would be generated literally in an unquoted argument in the test `CMakeLists.txt` file and would then be expanded. With quoting the `;` is preserved, which is not the old behavior. Fix this by expanding the `;`-list ahead of time. Add test cases for behavior with both `#` and `;`. This was noticed with the PGI compiler where we set `CMAKE_CXX*_STANDARD_COMPILE_OPTION` to values like `--c++17;-A`. The symptom had also been observed while preparing commit ef8f237686 (ParseImplicitIncludeInfo: add SunPro Fortran and PGI compiler, Cray fix, 2019-01-29, v3.14.0-rc1~26^2~2) but was not recognized at the time as a regression. Revert the workaround added by that commit. Fixes: #18919
* Revise C++ coding style using clang-format-6.0Kitware Robot2018-06-011-1/+1
| | | | | | | | | | | | Run the `clang-format.bash` script to update all our C and C++ code to a new style defined by `.clang-format`. Use `clang-format` version 6.0. * If you reached this commit for a line in `git blame`, re-run the blame operation starting at the parent of this commit to see older history for the content. * See the parent commit for instructions to rebase a change across this style transition commit.
* Various typo fixesLuz Paz2018-01-031-2/+2
| | | | Some are user-facing. Others are source comments.
* Use string(APPEND) in TestsDaniel Pfeifer2016-07-271-2/+2
| | | | | | | Automate with: find Tests -type f -print0 | xargs -0 perl -i -0pe \ 's/set\(([a-zA-Z0-9_]+)(\s+)"\$\{\1\}([^"])/string(APPEND \1\2"\3/g'
* Revise C++ coding style using clang-formatKitware Robot2016-05-168-19/+31
| | | | | | | | | | | | | Run the `Utilities/Scripts/clang-format.bash` script to update all our C++ code to a new style defined by `.clang-format`. Use `clang-format` version 3.8. * If you reached this commit for a line in `git blame`, re-run the blame operation starting at the parent of this commit to see older history for the content. * See the parent commit for instructions to rebase a change across this style transition commit.
* Drop Visual Studio 6 generatorBrad King2016-03-091-3/+1
| | | | | | This generator has been deprecated since CMake 3.3. Remove it. Update documentation, modules, and tests to drop content specific to this generator.
* Avoid if() quoted auto-dereferenceBen Boeckel2014-10-201-2/+2
| | | | | | | When testing CMAKE_<LANG>_COMPILER_ID values, do not explicitly dereference or quote the variable. We want if() to auto-dereference the variable and not its value. Also replace MATCHES with STREQUAL where equivalent.
* Merge topic 'try_compile-COPY_FILE_ERROR'Brad King2013-07-151-0/+17
|\ | | | | | | | | c28715b try_compile: Add COPY_FILE_ERROR option to capture failure
| * try_compile: Add COPY_FILE_ERROR option to capture failureBrad King2013-07-151-0/+17
| | | | | | | | | | | | | | | | | | | | | | When the COPY_FILE operation fails optionally capture the error message with a COPY_FILE_ERROR option instead of reporting the error immediately. This gives callers a chance to do something else or report the error. Teach the RunCMake.try_compile test to cover bad argument combinations involving COPY_FILE_ERROR. Teach the TryCompile test to cover the case of a COPY_FILE error message captured by COPY_FILE_ERROR.
* | try_compile: Escape CMAKE_<lang>_FLAGS in test projects (#14268)Brad King2013-07-152-0/+22
|/ | | | | | | | | If CMAKE_<lang>_FLAGS contains quotes or other CMake language characters they must be escaped when written into the generated CMakeLists.txt file so that the test project parses them properly. Teach the TryCompile test to cover this case by adding a flag with quotes into CMAKE_C_FLAGS during a C language try_compile.
* try_compile: Add signature to allow multiple SOURCESBrad King2013-06-065-0/+23
| | | | | | | | | | | | | | | | | Extend the signature try_compile(RESULT_VAR <bindir> <srcfile> ...) to allow multiple sources as try_compile(RESULT_VAR <bindir> SOURCES <srcfile>... ...) Process the sources to generate a CMakeLists.txt that enables all needed languages. Teach the TryCompile test to try cases with two sources of the same language and of mixed languages. Teach RunCMake.try_compile to cover error cases for the signature.
* Remove CMake-language block-end command argumentsKitware Robot2012-08-131-35/+35
| | | | | | | | | | | | | | | | | Ancient versions of CMake required else(), endif(), and similar block termination commands to have arguments matching the command starting the block. This is no longer the preferred style. Run the following shell code: for c in else endif endforeach endfunction endmacro endwhile; do echo 's/\b'"$c"'\(\s*\)(.\+)/'"$c"'\1()/' done >convert.sed && git ls-files -z -- bootstrap '*.cmake' '*.cmake.in' '*CMakeLists.txt' | egrep -z -v '^(Utilities/cm|Source/kwsys/)' | egrep -z -v 'Tests/CMakeTests/While-Endwhile-' | xargs -0 sed -i -f convert.sed && rm convert.sed
* Convert CMake-language commands to lower caseKitware Robot2012-08-131-128/+128
| | | | | | | | | | | | | | | | | Ancient CMake versions required upper-case commands. Later command names became case-insensitive. Now the preferred style is lower-case. Run the following shell code: cmake --help-command-list | grep -v "cmake version" | while read c; do echo 's/\b'"$(echo $c | tr '[:lower:]' '[:upper:]')"'\(\s*\)(/'"$c"'\1(/g' done >convert.sed && git ls-files -z -- bootstrap '*.cmake' '*.cmake.in' '*CMakeLists.txt' | egrep -z -v '^(Utilities/cm|Source/kwsys/)' | xargs -0 sed -i -f convert.sed && rm convert.sed
* Remove trailing whitespace from most CMake and C/C++ codeKitware Robot2012-08-133-13/+13
| | | | | | | | | | | | | | | | | Our Git commit hooks disallow modification or addition of lines with trailing whitespace. Wipe out all remnants of trailing whitespace everywhere except third-party code. Run the following shell code: git ls-files -z -- \ bootstrap doxygen.config '*.readme' \ '*.c' '*.cmake' '*.cpp' '*.cxx' \ '*.el' '*.f' '*.f90' '*.h' '*.in' '*.in.l' '*.java' \ '*.mm' '*.pike' '*.py' '*.txt' '*.vim' | egrep -z -v '^(Utilities/cm|Source/(kwsys|CursesDialog/form)/)' | egrep -z -v '^(Modules/CPack\..*\.in)' | xargs -0 sed -i 's/ \+$//'
* Tests: Added test for check_prototype_definition.Andreas Schneider2011-03-181-0/+13
|
* CheckCCompilerFlag: Strict signature of 'main' (#11615)Brad King2010-12-161-0/+6
| | | | | | Use "int main(void)" instead of just "int main()" so that compiling with "gcc -Werror=strict-prototypes" works. Test this check using the flags "-Werror -Wstrict-prototypes" to work with old GCC versions.
* Avoid PathScale cmd-line bug in TryCompile testBrad King2010-01-251-2/+8
| | | | | | | | | | | | | | | | | | | | The PathScale compiler silently accepts unknown options that start in more than one '-': $ touch foo.c $ pathcc -c foo.c --junk $ echo $? 0 $ pathcc -c foo.c ---junk $ echo $? 0 $ pathcc -c foo.c -junk pathcc ERROR parsing -junk: unknown flag $ echo $? 2 We teach the TryCompile to pass a bogus flag with only one '-' instead of three '-'s for this compiler.
* Add more coverage and use the ARGS option of try_runBill Hoffman2009-10-292-0/+33
|
* Fix CHECK_(C|CXX)_COMPILER_FLAG macro testBrad King2009-09-181-2/+2
| | | | | | The flag "-_this_is_not_a_flag_" was not rejected by GCC 4.0 on older Mac OS X. We now use "---_this_is_not_a_flag_" instead, which will hopefully be rejected by all compilers.
* Test CHECK_(C|CXX)_COMPILER_FLAG macrosBrad King2009-09-171-1/+9
| | | | | This teaches the TryCompile test to check that the compiler flag check macros correctly reject a bad flag. See issue #9516.
* No /fast targets in try_compile project modeBrad King2009-08-044-3/+9
| | | | | | | | The try_compile command builds the cmTryCompileExec executable using the cmTryCompileExec/fast target with Makefile generators in order to save time since dependencies are not needed. However, in project mode the command builds an entire source tree that may have dependencies. Therefore we can use the /fast target approach only in one-source mode.
* Fix recursive try_compile callsBrad King2009-08-031-0/+9
| | | | | | | | When building an entire source tree with try_compile instead of just a single source file, it is possible that the CMakeLists.txt file in the try-compiled project invokes try_compile. This commit fixes propagation of language-initialization results from the outer-most project into any number of try-compile levels.
* Test try_compile project modeBrad King2009-08-032-0/+11
| | | | | | | The try_compile command project mode builds an entire source tree instead of one source file. It uses an existing CMakeLists.txt file in the given source tree instead of generating one. This commit creates a test for the mode in the TryCompile test.
* ENH: remove test that does not work on all compilersBill Hoffman2008-07-161-32/+0
|
* ENH: add a test for bug 7316Bill Hoffman2008-07-151-0/+33
|