summaryrefslogtreecommitdiffstats
path: root/Tests/TryCompile
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2022-02-16 18:28:12 (GMT)
committerBrad King <brad.king@kitware.com>2022-02-16 18:28:12 (GMT)
commit4b47c4d0cd6f51b08f72113565a7a8bb6a1ad982 (patch)
treea2030190f4df2b74dd348db00c67c858876e06f8 /Tests/TryCompile
parent1e495fdab92b8ce5f2778c0cbc5e0ed55b056b98 (diff)
downloadCMake-4b47c4d0cd6f51b08f72113565a7a8bb6a1ad982.zip
CMake-4b47c4d0cd6f51b08f72113565a7a8bb6a1ad982.tar.gz
CMake-4b47c4d0cd6f51b08f72113565a7a8bb6a1ad982.tar.bz2
Tests: Use idiomatic try_compile calls in TryCompile test
Do not duplicate the `CMakeFiles/CMakeTmp` portion of the path. The `try_compile` command adds that automatically.
Diffstat (limited to 'Tests/TryCompile')
-rw-r--r--Tests/TryCompile/CMakeLists.txt34
-rw-r--r--Tests/TryCompile/Inner/CMakeLists.txt2
2 files changed, 18 insertions, 18 deletions
diff --git a/Tests/TryCompile/CMakeLists.txt b/Tests/TryCompile/CMakeLists.txt
index b1b9d57..594f37a 100644
--- a/Tests/TryCompile/CMakeLists.txt
+++ b/Tests/TryCompile/CMakeLists.txt
@@ -32,7 +32,7 @@ endmacro()
# try to compile a file that should compile
# also check that COPY_FILE works
try_compile(SHOULD_PASS
- ${TryCompile_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp
+ ${TryCompile_BINARY_DIR}
${TryCompile_SOURCE_DIR}/pass.c
OUTPUT_VARIABLE TRY_OUT
COPY_FILE ${TryCompile_BINARY_DIR}/CopyOfPass
@@ -51,7 +51,7 @@ endif()
# also check that COPY_FILE_ERROR works
file(WRITE ${TryCompile_BINARY_DIR}/invalid "")
try_compile(SHOULD_PASS
- ${TryCompile_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp
+ ${TryCompile_BINARY_DIR}
${TryCompile_SOURCE_DIR}/pass.c
OUTPUT_VARIABLE TRY_OUT
COPY_FILE ${TryCompile_BINARY_DIR}/invalid/path
@@ -66,7 +66,7 @@ endif()
# try to compile a file that should not compile
try_compile(SHOULD_FAIL
- ${TryCompile_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp
+ ${TryCompile_BINARY_DIR}
${TryCompile_SOURCE_DIR}/fail.c
OUTPUT_VARIABLE TRY_OUT)
if(SHOULD_FAIL)
@@ -75,7 +75,7 @@ endif()
# try to compile a file that should compile
try_compile(SHOULD_PASS
- ${TryCompile_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp
+ ${TryCompile_BINARY_DIR}
${TryCompile_SOURCE_DIR}/pass.c
OUTPUT_VARIABLE TRY_OUT)
if(NOT SHOULD_PASS)
@@ -84,7 +84,7 @@ endif()
# try to compile a file that should not compile
try_compile(SHOULD_FAIL
- ${TryCompile_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp
+ ${TryCompile_BINARY_DIR}
${TryCompile_SOURCE_DIR}/fail.c
OUTPUT_VARIABLE TRY_OUT)
if(SHOULD_FAIL)
@@ -93,7 +93,7 @@ endif()
# try to compile two files that should compile
try_compile(SHOULD_PASS
- ${TryCompile_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp
+ ${TryCompile_BINARY_DIR}
SOURCES ${TryCompile_SOURCE_DIR}/pass2a.c ${TryCompile_SOURCE_DIR}/pass2b.cxx
OUTPUT_VARIABLE TRY_OUT)
if(NOT SHOULD_PASS)
@@ -102,7 +102,7 @@ endif()
# try to compile two files that should not compile
try_compile(SHOULD_FAIL
- ${TryCompile_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp
+ ${TryCompile_BINARY_DIR}
SOURCES ${TryCompile_SOURCE_DIR}/fail2a.c ${TryCompile_SOURCE_DIR}/fail2b.c
OUTPUT_VARIABLE TRY_OUT)
if(SHOULD_FAIL)
@@ -117,7 +117,7 @@ else()
string(APPEND CMAKE_C_FLAGS " \"-DTESTDEF\"")
endif()
try_compile(SHOULD_PASS
- ${TryCompile_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp
+ ${TryCompile_BINARY_DIR}
${TryCompile_SOURCE_DIR}/testdef.c
OUTPUT_VARIABLE TRY_OUT)
if(NOT SHOULD_PASS)
@@ -135,7 +135,7 @@ else()
message("Test failed")
endif()
try_compile(CMAKE_ANSI_FOR_SCOPE
- ${TryCompile_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp
+ ${TryCompile_BINARY_DIR}
${CMAKE_ROOT}/Modules/TestForAnsiForScope.cxx OUTPUT_VARIABLE OUT)
if (CMAKE_ANSI_FOR_SCOPE)
message("Compiler supports ansi for")
@@ -144,7 +144,7 @@ else()
endif()
try_compile(CMAKE_ANSI_FOR_SCOPE
- ${TryCompile_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp
+ ${TryCompile_BINARY_DIR}
${CMAKE_ROOT}/Modules/TestForAnsiForScope.cxx OUTPUT_VARIABLE OUT)
if (CMAKE_ANSI_FOR_SCOPE)
message("Compiler supports ansi for")
@@ -169,7 +169,7 @@ try_compile(TEST_INNER
TEST_ASSERT(TEST_INNER "try_compile project mode failed:\n${output}")
try_compile(COMPILE_DEFINITIONS_LIST_EXPANDED
- ${TryCompile_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp
+ ${TryCompile_BINARY_DIR}
${TryCompile_SOURCE_DIR}/check_a_b.c
OUTPUT_VARIABLE output
COMPILE_DEFINITIONS "-DDEF_A;-DDEF_B"
@@ -182,7 +182,7 @@ else()
endif()
try_compile(SHOULD_FAIL_DUE_TO_BAD_SOURCE
- ${TryCompile_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp
+ ${TryCompile_BINARY_DIR}
${TryCompile_SOURCE_DIR}/pass.c
OUTPUT_VARIABLE output
COMPILE_DEFINITIONS "bad#source.c"
@@ -207,7 +207,7 @@ add_executable(TryCompile pass.c)
# also check that OUTPUT_VARIABLE contains both the compile output
# and the run output
try_run(SHOULD_RUN SHOULD_COMPILE
- ${TryCompile_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp
+ ${TryCompile_BINARY_DIR}
${TryCompile_SOURCE_DIR}/exit_success.c
OUTPUT_VARIABLE TRY_OUT)
if(NOT SHOULD_COMPILE)
@@ -226,7 +226,7 @@ if(NOT "${TRY_OUT}" MATCHES "hello world")
endif()
try_run(ARG_TEST_RUN ARG_TEST_COMPILE
- ${TryCompile_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp
+ ${TryCompile_BINARY_DIR}
${TryCompile_SOURCE_DIR}/expect_arg.c
OUTPUT_VARIABLE TRY_OUT
ARGS arg1 arg2)
@@ -239,7 +239,7 @@ endif()
# try to run a file that should compile and run, but return an error
try_run(SHOULD_EXIT_WITH_ERROR SHOULD_COMPILE
- ${TryCompile_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp
+ ${TryCompile_BINARY_DIR}
${TryCompile_SOURCE_DIR}/exit_with_error.c
COMPILE_OUTPUT_VARIABLE COMPILE_OUTPUT
RUN_OUTPUT_VARIABLE RUN_OUTPUT)
@@ -385,7 +385,7 @@ if (APPLE)
# try to compile a file that should compile
try_compile(SHOULD_PASS
- ${TryCompile_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp
+ ${TryCompile_BINARY_DIR}
${TryCompile_SOURCE_DIR}/pass.m
OUTPUT_VARIABLE TRY_OUT)
if(NOT SHOULD_PASS)
@@ -394,7 +394,7 @@ if (APPLE)
# try to compile a file that should not compile
try_compile(SHOULD_FAIL
- ${TryCompile_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp
+ ${TryCompile_BINARY_DIR}
${TryCompile_SOURCE_DIR}/fail.m
OUTPUT_VARIABLE TRY_OUT)
if(SHOULD_FAIL)
diff --git a/Tests/TryCompile/Inner/CMakeLists.txt b/Tests/TryCompile/Inner/CMakeLists.txt
index d8c22d0..9f89af2 100644
--- a/Tests/TryCompile/Inner/CMakeLists.txt
+++ b/Tests/TryCompile/Inner/CMakeLists.txt
@@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 2.8.12)
project(TryCompileInner C)
try_compile(SHOULD_PASS
- ${TryCompileInner_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp
+ ${TryCompileInner_BINARY_DIR}
${TryCompileInner_SOURCE_DIR}/../pass.c
OUTPUT_VARIABLE TRY_OUT
)