Changeset: f987ff46fc69 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=f987ff46fc69 Modified Files: cmake/monetdb-functions.cmake ctest/cmake/set-cmake-vars.cmake ctest/cmake/set-dir-vars.cmake Branch: default Log Message:
move some of the cmake unittests into a function diffs (truncated from 315 to 300 lines): diff --git a/cmake/monetdb-functions.cmake b/cmake/monetdb-functions.cmake --- a/cmake/monetdb-functions.cmake +++ b/cmake/monetdb-functions.cmake @@ -146,3 +146,22 @@ function(monetdb_cmake_summary) message(STATUS "-----------------------------------------") message(STATUS "") endfunction() + +function(assert_variable_exists assert_variable_variablename) + if(NOT ${assert_variable_variablename}) + message(FATAL_ERROR "variable ${assert_variable_variablename} not defined") + set(DETECT "1") + else() + set(DETECT "0") + endif() + + configure_file(test_cmake_var.c.in + "${CMAKE_CURRENT_BINARY_DIR}/test_${assert_variable_variablename}_var.c" + @ONLY) + + add_executable("test_${assert_variable_variablename}_var") + target_sources("test_${assert_variable_variablename}_var" + PRIVATE + "${CMAKE_CURRENT_BINARY_DIR}/test_${assert_variable_variablename}_var.c") + add_test("testDetect${assert_variable_variablename}" "test_${assert_variable_variablename}_var") +endfunction() diff --git a/ctest/cmake/set-cmake-vars.cmake b/ctest/cmake/set-cmake-vars.cmake --- a/ctest/cmake/set-cmake-vars.cmake +++ b/ctest/cmake/set-cmake-vars.cmake @@ -9,57 +9,12 @@ # Test for the existance of these cmake variables, the source code assumes # that they are set by the buildsystem. -if(NOT DEFINED HAVE_CUDF) - message(FATAL_ERROR "variable HAVE_CUDF not defined") - set(DETECT "1") -else() - set(DETECT "0") -endif() - -configure_file(test_cmake_var.c.in - ${CMAKE_CURRENT_BINARY_DIR}/test_have_cudf_var.c - @ONLY) - -add_executable(test_have_cudf_var) -target_sources(test_have_cudf_var - PRIVATE - ${CMAKE_CURRENT_BINARY_DIR}/test_have_cudf_var.c) -add_test(testDetectHave_cudf test_have_cudf_var) +assert_variable_exists(HAVE_CUDF) -if(DEFINED HAVE_LIBR) - if(NOT DEFINED RHOME) - message(FATAL_ERROR "variable RHOME not defined") - set(DETECT "1") - else() - set(DETECT "0") - endif() - - configure_file(test_cmake_var.c.in - ${CMAKE_CURRENT_BINARY_DIR}/test_rhome_var.c - @ONLY) - - add_executable(test_rhome_var) - target_sources(test_rhome_var - PRIVATE - ${CMAKE_CURRENT_BINARY_DIR}/test_rhome_var.c) - add_test(testDetectRhome test_rhome_var) +if(HAVE_LIBR) + assert_variable_exists(RHOME) endif() if(DEFINED HAVE_GETOPT_H) - if(NOT DEFINED HAVE_GETOPT) - message(FATAL_ERROR "variable HAVE_GETOPT not defined") - set(DETECT "1") - else() - set(DETECT "0") - endif() - - configure_file(test_cmake_var.c.in - ${CMAKE_CURRENT_BINARY_DIR}/test_have_getopt1_var.c - @ONLY) - - add_executable(test_have_getopt1_var) - target_sources(test_have_getopt1_var - PRIVATE - ${CMAKE_CURRENT_BINARY_DIR}/test_have_getopt1_var.c) - add_test(testDetectHave_getopt1 test_have_getopt1_var) + assert_variable_exists(HAVE_GETOPT) endif() diff --git a/ctest/cmake/set-dir-vars.cmake b/ctest/cmake/set-dir-vars.cmake --- a/ctest/cmake/set-dir-vars.cmake +++ b/ctest/cmake/set-dir-vars.cmake @@ -8,210 +8,14 @@ # Test for the existance of these cmake variables, the source code assumes # that they are set by the buildsystem. -#if(NOT DEFINED BIN_DIR) -# message(FATAL_ERROR "variable BIN_DIR not defined") -# set(DETECT "1") -#else() -# set(DETECT "0") -#endif() -#configure_file(test_cmake_var.c.in -# ${CMAKE_CURRENT_BINARY_DIR}/test_bin_dir_var.c -# @ONLY) - -#add_executable(test_bin_dir_var) -#target_sources(test_bin_dir_var -# PRIVATE -# ${CMAKE_CURRENT_BINARY_DIR}/test_bin_dir_var.c) -#add_test(testDetectBin_dir test_bin_dir_var) - -if(NOT DEFINED DIR_SEP) - message(FATAL_ERROR "variable DIR_SEP not defined") - set(DETECT "1") -else() - set(DETECT "0") -endif() - -configure_file(test_cmake_var.c.in - ${CMAKE_CURRENT_BINARY_DIR}/test_dir_sep_var.c - @ONLY) - -add_executable(test_dir_sep_var) -target_sources(test_dir_sep_var - PRIVATE - ${CMAKE_CURRENT_BINARY_DIR}/test_dir_sep_var.c) -add_test(testDetectDir_sep test_dir_sep_var) - -if(NOT DEFINED PKGCONFIGDIR) - message(FATAL_ERROR "variable PKGCONFIGDIR not defined") - set(DETECT "1") -else() - set(DETECT "0") -endif() - -configure_file(test_cmake_var.c.in - ${CMAKE_CURRENT_BINARY_DIR}/test_pkgconfigdir_var.c - @ONLY) - -add_executable(test_pkgconfigdir_var) -target_sources(test_pkgconfigdir_var - PRIVATE - ${CMAKE_CURRENT_BINARY_DIR}/test_pkgconfigdir_var.c) -add_test(testDetectPkgconfigdir test_pkgconfigdir_var) - -if(NOT DEFINED BINDIR) - message(FATAL_ERROR "variable BINDIR not defined") - set(DETECT "1") -else() - set(DETECT "0") -endif() - -configure_file(test_cmake_var.c.in - ${CMAKE_CURRENT_BINARY_DIR}/test_bindir_var.c - @ONLY) - -add_executable(test_bindir_var) -target_sources(test_bindir_var - PRIVATE - ${CMAKE_CURRENT_BINARY_DIR}/test_bindir_var.c) -add_test(testDetectBindir test_bindir_var) - -if(NOT DEFINED LOCALSTATEDIR) - message(FATAL_ERROR "variable LOCALSTATEDIR not defined") - set(DETECT "1") -else() - set(DETECT "0") -endif() - -configure_file(test_cmake_var.c.in - ${CMAKE_CURRENT_BINARY_DIR}/test_localstatedir_var.c - @ONLY) - -add_executable(test_localstatedir_var) -target_sources(test_localstatedir_var - PRIVATE - ${CMAKE_CURRENT_BINARY_DIR}/test_localstatedir_var.c) -add_test(testDetectLocalstatedir test_localstatedir_var) - -if(NOT DEFINED DIR_SEP_STR) - message(FATAL_ERROR "variable DIR_SEP_STR not defined") - set(DETECT "1") -else() - set(DETECT "0") -endif() - -configure_file(test_cmake_var.c.in - ${CMAKE_CURRENT_BINARY_DIR}/test_dir_sep_str_var.c - @ONLY) - -add_executable(test_dir_sep_str_var) -target_sources(test_dir_sep_str_var - PRIVATE - ${CMAKE_CURRENT_BINARY_DIR}/test_dir_sep_str_var.c) -add_test(testDetectDir_sep_str test_dir_sep_str_var) - -if(NOT DEFINED PATH_SEP) - message(FATAL_ERROR "variable PATH_SEP not defined") - set(DETECT "1") -else() - set(DETECT "0") -endif() - -configure_file(test_cmake_var.c.in - ${CMAKE_CURRENT_BINARY_DIR}/test_path_sep_var.c - @ONLY) - -add_executable(test_path_sep_var) -target_sources(test_path_sep_var - PRIVATE - ${CMAKE_CURRENT_BINARY_DIR}/test_path_sep_var.c) -add_test(testDetectPath_sep test_path_sep_var) - -if(NOT DEFINED SO_PREFIX) - message(FATAL_ERROR "variable SO_PREFIX not defined") - set(DETECT "1") -else() - set(DETECT "0") -endif() - -configure_file(test_cmake_var.c.in - ${CMAKE_CURRENT_BINARY_DIR}/test_so_prefix_var.c - @ONLY) - -add_executable(test_so_prefix_var) -target_sources(test_so_prefix_var - PRIVATE - ${CMAKE_CURRENT_BINARY_DIR}/test_so_prefix_var.c) -add_test(testDetectSo_prefix test_so_prefix_var) - -if(NOT DEFINED SO_EXT) - message(FATAL_ERROR "variable SO_EXT not defined") - set(DETECT "1") -else() - set(DETECT "0") -endif() - -configure_file(test_cmake_var.c.in - ${CMAKE_CURRENT_BINARY_DIR}/test_so_ext_var.c - @ONLY) - -add_executable(test_so_ext_var) -target_sources(test_so_ext_var - PRIVATE - ${CMAKE_CURRENT_BINARY_DIR}/test_so_ext_var.c) -add_test(testDetectSo_ext test_so_ext_var) - -if(NOT DEFINED LIBDIR) - message(FATAL_ERROR "variable LIBDIR not defined") - set(DETECT "1") -else() - set(DETECT "0") -endif() - -configure_file(test_cmake_var.c.in - ${CMAKE_CURRENT_BINARY_DIR}/test_libdir_var.c - @ONLY) - -add_executable(test_libdir_var) -target_sources(test_libdir_var - PRIVATE - ${CMAKE_CURRENT_BINARY_DIR}/test_libdir_var.c) -add_test(testDetectLibdir test_libdir_var) - -if(DEFINED HAVE_GETOPT_H) - if(NOT DEFINED HAVE_GETOPT) - message(FATAL_ERROR "variable HAVE_GETOPT not defined") - set(DETECT "1") - else() - set(DETECT "0") - endif() - - configure_file(test_cmake_var.c.in - ${CMAKE_CURRENT_BINARY_DIR}/test_have_getopt_var.c - @ONLY) - - add_executable(test_have_getopt_var) - target_sources(test_have_getopt_var - PRIVATE - ${CMAKE_CURRENT_BINARY_DIR}/test_have_getopt_var.c) - add_test(testDetectHave_getopt test_have_getopt_var) -endif() - -if(NOT DEFINED ENABLE_STATIC_ANALYSIS) - message(FATAL_ERROR "variable ENABLE_STATIC_ANALYSIS not defined") - set(DETECT "1") -else() - set(DETECT "0") -endif() - -configure_file(test_cmake_var.c.in - ${CMAKE_CURRENT_BINARY_DIR}/test_enable_static_var.c - @ONLY) - -add_executable(test_enable_static_var) -target_sources(test_enable_static_var _______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list