### Configure and Install Man Pages Source: https://github.com/libcheck/check/blob/master/doc/man/man3/CMakeLists.txt Iterates through a list of man pages, configures them with project version, and installs them to the system man directory. The installation is optional and can be filtered by component. ```cmake FOREACH(MAN3_PAGE ${MAN3_PAGES}) CONFIGURE_FILE(${MAN3_PAGE}.in ${MAN3_PAGE} @ONLY) INSTALL( FILES ${CMAKE_CURRENT_BINARY_DIR}/${MAN3_PAGE} DESTINATION ${CMAKE_INSTALL_MANDIR}/man3 PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ CONFIGURATIONS Debug Release COMPONENT docs OPTIONAL ) ENDFOREACH() ``` -------------------------------- ### Configure and Install Section 7 Man Pages Source: https://github.com/libcheck/check/blob/master/doc/man/man7/CMakeLists.txt Iterates through the defined man pages, configures them by adding the project version, and then installs them to the appropriate system directory. The installation can be filtered by component, such as 'docs'. ```cmake FOREACH(MAN7_PAGE ${MAN7_PAGES}) # Configure the man pages. # # The configuration of each man page involves only the # addition of the library version number defined in the # configure.ac file to each man page. # CONFIGURE_FILE(${MAN7_PAGE}.in ${MAN7_PAGE} @ONLY) # Install Section 7 Man Pages (Overview, Conventions, ...) # # This directive describes what, where, how, and when the # section 7 man pages should be installed. Specifically, the # ${CMAKE_INSTALL_MANDIR} variable provided by the # GNUInstallDirs module specifies the system-specific man # page installation directory, the permissions set the # desired installed file(s) permissions, the configurations # directive specifies that this directive applies for both # Debug and Release configurations, and the component # directive allows for the installation of only those items # belonging to the docs component. # # For example, to install only the 'docs' component, the # following command can be used after generating the project # build files. # # $ cmake --install . --component docs # # This example assumes the project build files were # generated in the current working directory. # INSTALL( FILES ${CMAKE_CURRENT_BINARY_DIR}/${MAN7_PAGE} DESTINATION ${CMAKE_INSTALL_MANDIR}/man7 PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ CONFIGURATIONS Debug Release COMPONENT docs OPTIONAL ) ENDFOREACH() ``` -------------------------------- ### Install Header File Source: https://github.com/libcheck/check/blob/master/doc/example/src/CMakeLists.txt Installs the 'money.h' header file to the include directory. ```cmake install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/money.h DESTINATION include) ``` -------------------------------- ### Install Check using Autoconf Source: https://github.com/libcheck/check/blob/master/README.md Build and install Check using the autoconf build system. Ensure the linker cache is updated after installation. ```bash $ autoreconf --install $ ./configure $ make $ make check $ make install $ sudo ldconfig ``` -------------------------------- ### Install Library Artifacts Source: https://github.com/libcheck/check/blob/master/doc/example/src/CMakeLists.txt Installs the 'money' library to specified runtime, library, and archive destinations. ```cmake install(TARGETS money RUNTIME DESTINATION bin LIBRARY DESTINATION lib ARCHIVE DESTINATION lib) ``` -------------------------------- ### Install Package Configuration Files Source: https://github.com/libcheck/check/blob/master/CMakeLists.txt Installs the generated configuration and version files to the appropriate location for CMake to find them. ```cmake install( FILES "${CMAKE_CURRENT_BINARY_DIR}/cmake/${EXPORT_NAME}-config.cmake" "${CMAKE_CURRENT_BINARY_DIR}/cmake/${EXPORT_NAME}-config-version.cmake" DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${EXPORT_NAME} ) ``` -------------------------------- ### Install Check via Homebrew on OSX Source: https://github.com/libcheck/check/blob/master/web/install.html Install the Check package using Homebrew on OSX. Ensure Homebrew is installed first. ```bash brew install check ``` -------------------------------- ### Install Check on Ubuntu/Debian Source: https://github.com/libcheck/check/blob/master/web/install.html Use apt-get to install the Check package on Ubuntu or Debian systems. ```bash sudo apt-get install check ``` -------------------------------- ### Install Check on MinGW/MinGW-w64 from Source Source: https://github.com/libcheck/check/blob/master/web/install.html Build process for Check on MinGW/MinGW-w64. Fork mode will be disabled due to the absence of a fork() alternative. ```bash ./configure make make check make install ``` -------------------------------- ### Install Checkmk Executable and Man Pages Source: https://github.com/libcheck/check/blob/master/checkmk/CMakeLists.txt Installs the Checkmk executable and its man pages if the INSTALL_CHECKMK option is enabled. Sets specific file permissions for the executable. ```cmake option(INSTALL_CHECKMK "Install checkmk" ON) if(INSTALL_CHECKMK AND NOT THIS_IS_SUBPROJECT) install( FILES ${CMAKE_CURRENT_BINARY_DIR}/checkmk DESTINATION ${CMAKE_INSTALL_BINDIR} PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE ) install( DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/man DESTINATION ${CMAKE_INSTALL_DATAROOTDIR} ) endif() ``` -------------------------------- ### Copy Documentation File Source: https://github.com/libcheck/check/blob/master/checkmk/CMakeLists.txt Copies a documentation file from the source directory to the installation destination. Specifically copies the man page for checkmk. ```cmake file(COPY doc/checkmk.1 DESTINATION man/man1) ``` -------------------------------- ### Install Check via Packages on OpenBSD Source: https://github.com/libcheck/check/blob/master/web/install.html Use pkg_add to install the Check package on OpenBSD systems. ```bash sudo pkg_add check ``` -------------------------------- ### Install Check via MacPorts on OSX Source: https://github.com/libcheck/check/blob/master/web/install.html Install the Check package using MacPorts on OSX. Ensure MacPorts is installed first. ```bash sudo port install check ``` -------------------------------- ### Install Check on Arch Linux Source: https://github.com/libcheck/check/blob/master/web/install.html Use pacman to install the Check package on Arch Linux systems. ```bash sudo pacman -S check ``` -------------------------------- ### Install Check on Fedora Source: https://github.com/libcheck/check/blob/master/web/install.html Use yum to install the Check package on Fedora systems. ```bash sudo yum install check ``` -------------------------------- ### Defining Example Output Executable Source: https://github.com/libcheck/check/blob/master/tests/CMakeLists.txt Defines the 'ex_output' executable, specifying its source file and linking it against the 'check' library. ```cmake set(EX_OUTPUT_SOURCES ex_output.c) add_executable(ex_output ${EX_OUTPUT_SOURCES}) target_link_libraries(ex_output check) ``` -------------------------------- ### Install Check Library Targets Source: https://github.com/libcheck/check/blob/master/src/CMakeLists.txt Installs the static and shared 'check' library targets, along with their headers, to the appropriate locations based on CMAKE_INSTALL_LIBDIR, CMAKE_INSTALL_BINDIR, and CMAKE_INSTALL_INCLUDEDIR. ```cmake if(NOT THIS_IS_SUBPROJECT) install(TARGETS check checkShared EXPORT check-targets ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} ) endif() ``` -------------------------------- ### Set Check Install Directory (Optional) Source: https://github.com/libcheck/check/blob/master/doc/example/tests/CMakeLists.txt Optionally sets the installation directory for the Check library if pkg-config is not available. This is particularly useful on Windows. ```cmake set(CHECK_INSTALL_DIR "C:/Program Files/check") ``` -------------------------------- ### Install Check using CMake Source: https://github.com/libcheck/check/blob/master/README.md Build and test Check using the cmake build system. Set CTEST_OUTPUT_ON_FAILURE to see test output on failure. ```bash $ mkdir build $ cd build $ cmake ../ $ make $ CTEST_OUTPUT_ON_FAILURE=1 make test ``` -------------------------------- ### Visual Studio Build Targets for Check Source: https://github.com/libcheck/check/blob/master/web/install.html Key build targets within the Visual Studio project for Check. Use these to compile, test, and install the library. ```text ALL_BUILD: Build Check and all unit tests RUN_TESTS: Execute Check's unit tests INSTALL: Install Check to the CMAKE_INSTALL_PREFIX location ``` -------------------------------- ### Define Section 7 Man Pages Source: https://github.com/libcheck/check/blob/master/doc/man/man7/CMakeLists.txt Defines a list of section 7 man page files to be processed. This is the initial step before configuration and installation. ```cmake SET(MAN7_PAGES libcheck.7 ) ``` -------------------------------- ### Include Check using find_package(CONFIG) Source: https://github.com/libcheck/check/blob/master/tests/cmake_project_usage_test/src/CMakeLists.txt Use find_package with the CONFIG option to locate and use a pre-installed Check library. This is the preferred method for production environments where the library is installed system-wide or in a known location. ```cmake elseif($ENV{INCLUDE_CHECK_WITH} STREQUAL "find_package_config") set(Check_ROOT "" CACHE PATH "Check installation root dir") find_package(Check 0.13.0 REQUIRED CONFIG) else() message(FATAL_ERROR "Variable INCLUDE_CHECK_WITH not properly set!") endif() ``` -------------------------------- ### Define Public Include Directories for Static Library Source: https://github.com/libcheck/check/blob/master/src/CMakeLists.txt Specifies public include directories for the static 'check' library, making headers available during build and installation. ```cmake target_include_directories(check PUBLIC $ $ $ ) ``` -------------------------------- ### Define Public Include Directories for Shared Library Source: https://github.com/libcheck/check/blob/master/src/CMakeLists.txt Specifies public include directories for the shared 'checkShared' library, making headers available during build and installation. ```cmake target_include_directories(checkShared PUBLIC $ $ $ ) ``` -------------------------------- ### Pthread Detection Loop Source: https://github.com/libcheck/check/blob/master/m4/acx_pthread.html Iterates through potential flags to determine if pthreads work. It checks for 'none', flags starting with '-', 'pthread-config', and library names. ```shell if test x"$acx_pthread_ok" = xno; then for flag in $acx_pthread_flags; do case $flag in none) AC_MSG_CHECKING([whether pthreads work without any flags]) ;; -*) AC_MSG_CHECKING([whether pthreads work with $flag]) PTHREAD_CFLAGS="$flag" ;; pthread-config) AC_CHECK_PROG(acx_pthread_config, pthread-config, yes, no) if test x"$acx_pthread_config" = xno; then continue; fi PTHREAD_CFLAGS="`pthread-config --cflags`" PTHREAD_LIBS="`pthread-config --ldflags` `pthread-config --libs`" ;; *) AC_MSG_CHECKING([for the pthreads library -l$flag]) PTHREAD_LIBS="-l$flag" ;; esac save_LIBS="$LIBS" save_CFLAGS="$CFLAGS" LIBS="$PTHREAD_LIBS $LIBS" CFLAGS="$CFLAGS $PTHREAD_CFLAGS" # Check for various functions. We must include pthread.h, # since some functions may be macros. (On the Sequent, we # need a special flag -Kthread to make this header compile.) # We check for pthread_join because it is in -lpthread on IRIX # while pthread_create is in libc. We check for pthread_attr_init # due to DEC craziness with -lpthreads. We check for # pthread_cleanup_push because it is one of the few pthread # functions on Solaris that doesn't have a non-functional libc stub. # We try pthread_create on general principles. AC_TRY_LINK([#include ], [pthread_t th; pthread_join(th, 0); pthread_attr_init(0); pthread_cleanup_push(0, 0); pthread_create(0,0,0,0); pthread_cleanup_pop(0); ], [acx_pthread_ok=yes]) LIBS="$save_LIBS" CFLAGS="$save_CFLAGS" AC_MSG_RESULT($acx_pthread_ok) if test "x$acx_pthread_ok" = xyes; then break; fi PTHREAD_LIBS="" PTHREAD_CFLAGS="" done fi ``` -------------------------------- ### Register Package in User Registry Source: https://github.com/libcheck/check/blob/master/CMakeLists.txt Stores the current build directory in the CMake user package registry. This allows dependent projects to find and use the package from the build tree without installation. ```cmake export(PACKAGE "${PROJECT_NAME}") ``` -------------------------------- ### Create Executable and Link Library Source: https://github.com/libcheck/check/blob/master/doc/example/src/CMakeLists.txt Creates an executable target named 'main' and links it against the 'money' library. ```cmake add_executable(main ${HEADERS} ${MAIN_SOURCES}) target_link_libraries(main money) ``` -------------------------------- ### Create Executable and Link Test Suite Source: https://github.com/libcheck/check/blob/master/tests/cmake_project_usage_test/src/CMakeLists.txt Creates an executable named 'tests.test' from 'tests.c' and links it with the previously defined 'test_suite' library. ```cmake add_executable(tests.test tests.c) target_link_libraries(tests.test test_suite) ``` -------------------------------- ### Create Test Executable and Link Libraries Source: https://github.com/libcheck/check/blob/master/doc/example/tests/CMakeLists.txt Creates an executable named 'check_money' from the test sources and links it with the 'money' library and Check libraries. ```cmake add_executable(check_money ${TEST_SOURCES}) target_link_libraries(check_money money ${CHECK_LIBRARIES}) ``` -------------------------------- ### Include Check using FetchContent Source: https://github.com/libcheck/check/blob/master/tests/cmake_project_usage_test/src/CMakeLists.txt Use FetchContent to download and build the Check library directly from a URL. This method is suitable for development or when a pre-built package is not available. It handles different CMake versions for compatibility. ```cmake if($ENV{INCLUDE_CHECK_WITH} STREQUAL "FetchContent") include(FetchContent) FetchContent_Declare(check URL "$ENV{INCLUDE_CHECK_FROM}" # URL file://${DIR}/check ) if(CMAKE_VERSION VERSION_LESS "3.14") FetchContent_GetProperties(check) if(NOT check_POPULATED) FetchContent_Populate(check) add_subdirectory(${check_SOURCE_DIR} ${check_BINARY_DIR}) endif() else() FetchContent_MakeAvailable(check) endif() ``` -------------------------------- ### Create Static Library Source: https://github.com/libcheck/check/blob/master/doc/example/src/CMakeLists.txt Creates a static library target named 'money' using the specified source files and headers. ```cmake add_library(money STATIC ${LIB_SOURCES} ${HEADERS}) ``` -------------------------------- ### Configure File Source: https://github.com/libcheck/check/blob/master/checkmk/CMakeLists.txt Generates a configuration file by processing an input template. The '@ONLY' option means only @VAR@ style variables are substituted. ```cmake configure_file(checkmk.in checkmk @ONLY) ``` -------------------------------- ### Define Configure Input Message Source: https://github.com/libcheck/check/blob/master/checkmk/CMakeLists.txt Defines a string that describes the source of a generated configuration file. This helps in tracking how files are generated. ```cmake set(configure_input "Generated from ${conf_file} by configure.") ``` -------------------------------- ### Define Test Sources Source: https://github.com/libcheck/check/blob/master/doc/example/tests/CMakeLists.txt Lists the source files that will be compiled for the test executable. ```cmake set(TEST_SOURCES check_money.c ) ``` -------------------------------- ### Compile Check on Solaris with Solaris Studio Source: https://github.com/libcheck/check/blob/master/web/install.html Configure, build, and test Check on Solaris using autotools, specifying the Solaris Studio compiler. Assumes CFLAGS/LDFLAGS are set for 64-bit. ```bash CC=cc $ ./configure CFLAGS=-m64 LDFLAGS=-m64 $ gmake $ gmake check $ gmake install ``` -------------------------------- ### Define Library and Executable Sources Source: https://github.com/libcheck/check/blob/master/doc/example/src/CMakeLists.txt Defines lists of source files for a static library and an executable. Includes header files for both. ```cmake set(LIB_SOURCES money.c ) set(MAIN_SOURCES main.c ) set(HEADERS ${CONFIG_HEADER} money.h ) ``` -------------------------------- ### Generate Package Configuration Files Source: https://github.com/libcheck/check/blob/master/CMakeLists.txt Generates the main package configuration file and its version file. Use this to define how dependent projects find and use your library. ```cmake string(TOLOWER ${PROJECT_NAME} EXPORT_NAME) include(CMakePackageConfigHelpers) configure_package_config_file( ${CMAKE_CURRENT_SOURCE_DIR}/cmake/${EXPORT_NAME}-config.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/cmake/${EXPORT_NAME}-config.cmake INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/${EXPORT_NAME}/cmake ) write_basic_package_version_file( ${CMAKE_CURRENT_BINARY_DIR}/cmake/${EXPORT_NAME}-config-version.cmake VERSION ${PROJECT_VERSION} COMPATIBILITY AnyNewerVersion ) ``` -------------------------------- ### Compile Check on Windows with MSVC Source: https://github.com/libcheck/check/blob/master/web/install.html Use CMake to generate NMake Makefiles for building Check on Windows with MSVC. Ensure MSVC is in the PATH. ```bash > cmake -G "NMake Makefiles" . > nmake > nmake test > nmake install ``` -------------------------------- ### Configure Static Library Properties Source: https://github.com/libcheck/check/blob/master/src/CMakeLists.txt Sets the output name and public headers for the static 'check' library. ```cmake set(LIBRARY_OUTPUT_NAME "check") list(APPEND public_headers "${CMAKE_CURRENT_BINARY_DIR}/check.h") list(APPEND public_headers "${CMAKE_CURRENT_BINARY_DIR}/../check_stdint.h") set_target_properties(check PROPERTIES OUTPUT_NAME ${LIBRARY_OUTPUT_NAME} PUBLIC_HEADER "${public_headers}" ) ``` -------------------------------- ### Compile Check on Solaris with GCC Source: https://github.com/libcheck/check/blob/master/web/install.html Configure, build, and test Check on Solaris using autotools. Assumes GCC is the default compiler and CFLAGS/LDFLAGS are set for 64-bit. ```bash $ ./configure CFLAGS=-m64 LDFLAGS=-m64 $ gmake $ gmake check $ gmake install ``` -------------------------------- ### Include Project Source Directory Source: https://github.com/libcheck/check/blob/master/doc/example/tests/CMakeLists.txt Includes the source directory of the project for CMake to find header files. ```cmake include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../src) ``` -------------------------------- ### Compile Check from Source on GNU/Linux Source: https://github.com/libcheck/check/blob/master/web/install.html Standard autotools build process for compiling Check from source on GNU/Linux. Ensure you have the latest source downloaded and unpacked. ```bash ./configure make make check sudo make install ``` -------------------------------- ### Generate HTML Report with xsltproc Source: https://github.com/libcheck/check/blob/master/contrib/check_unittest.txt Command-line usage to transform Check's XML output to an HTML report using the xsltproc tool and the check_unittest.xslt stylesheet. ```bash $ xsltproc check_unittest.xslt check_output.xml > report.html ``` -------------------------------- ### Find and Include Check Package Source: https://github.com/libcheck/check/blob/master/doc/example/tests/CMakeLists.txt Finds the Check testing package and includes its directories for compilation and linking. ```cmake find_package(Check REQUIRED) include_directories(${CHECK_INCLUDE_DIRS}) link_directories(${CHECK_LIBRARY_DIRS}) ``` -------------------------------- ### Generate Visual Studio Project Files with CMake Source: https://github.com/libcheck/check/blob/master/web/install.html Steps to configure Check for Visual Studio using CMake. This process generates project files for building within Visual Studio. ```bash cmake .. -G "Visual Studio" ``` -------------------------------- ### Configure Shared Library Properties Source: https://github.com/libcheck/check/blob/master/src/CMakeLists.txt Sets the output name, version, and public headers for the shared 'checkShared' library. ```cmake set_target_properties(checkShared PROPERTIES OUTPUT_NAME ${LIBRARY_OUTPUT_NAME} VERSION ${PROJECT_VERSION} SOVERSION ${PROJECT_VERSION_MAJOR} PUBLIC_HEADER "${public_headers}" ) ``` -------------------------------- ### Setting Include Directories Source: https://github.com/libcheck/check/blob/master/tests/CMakeLists.txt Configures include paths for the Check framework's source and build directories. This ensures that header files are found during the build process. ```cmake include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../src) # Enable finding check.h include_directories(${CMAKE_CURRENT_BINARY_DIR}/../src) ``` -------------------------------- ### Configure Check for Cross-Compilation on BSD Source: https://github.com/libcheck/check/blob/master/web/install.html Use this configure argument when cross-compiling for BSD systems to disable the use of potentially non-functional high-resolution timers. ```bash ./configure --enable-timer-replacement ``` -------------------------------- ### Add Static Library Source: https://github.com/libcheck/check/blob/master/lib/CMakeLists.txt This snippet adds the libcheck compatibility library as a static library to the build. It uses the previously defined source and header files. ```cmake add_library(compat STATIC ${SOURCES} ${HEADERS}) ``` -------------------------------- ### Define Source Files for libcheck Source: https://github.com/libcheck/check/blob/master/lib/CMakeLists.txt This snippet defines the list of source files for the libcheck compatibility library. It includes core files and conditionally adds others based on system feature checks. ```cmake set(SOURCES libcompat.c) set(SOURCES ${SOURCES} fpclassify.c) ``` ```cmake if (NOT HAVE_LIBRT) set(SOURCES ${SOURCES} clock_gettime.c) set(SOURCES ${SOURCES} timer_create.c) set(SOURCES ${SOURCES} timer_delete.c) set(SOURCES ${SOURCES} timer_settime.c) endif(NOT HAVE_LIBRT) ``` ```cmake if(NOT HAVE_GETLINE) set(SOURCES ${SOURCES} getline.c) endif(NOT HAVE_GETLINE) ``` ```cmake if(NOT HAVE_GETTIMEOFDAY) set(SOURCES ${SOURCES} gettimeofday.c) endif(NOT HAVE_GETTIMEOFDAY) ``` ```cmake if(NOT HAVE_DECL_LOCALTIME_R) set(SOURCES ${SOURCES} localtime_r.c) endif(NOT HAVE_DECL_LOCALTIME_R) ``` ```cmake if(NOT HAVE_MALLOC) set(SOURCES ${SOURCES} malloc.c) endif(NOT HAVE_MALLOC) ``` ```cmake if(NOT HAVE_REALLOC) set(SOURCES ${SOURCES} realloc.c) endif(NOT HAVE_REALLOC) ``` ```cmake if(NOT HAVE_SNPRINTF) set(SOURCES ${SOURCES} snprintf.c) endif(NOT HAVE_SNPRINTF) ``` ```cmake if(NOT HAVE_DECL_STRDUP AND NOT HAVE__STRDUP) set(SOURCES ${SOURCES} strdup.c) endif(NOT HAVE_DECL_STRDUP AND NOT HAVE__STRDUP) ``` ```cmake if(NOT HAVE_DECL_STRSIGNAL) set(SOURCES ${SOURCES} strsignal.c) endif(NOT HAVE_DECL_STRSIGNAL) ``` ```cmake if(NOT HAVE_DECL_ALARM) set(SOURCES ${SOURCES} alarm.c) endif(NOT HAVE_DECL_ALARM) ``` ```cmake if (NOT HAVE_PTHREAD) set(SOURCES ${SOURCES} pthread_mutex.c) endif() ``` -------------------------------- ### Configuring Test Variables Source: https://github.com/libcheck/check/blob/master/tests/CMakeLists.txt Configures the test_vars.in script to generate test_vars, providing test runners with necessary variables like source directory locations. ```cmake configure_file(${CMAKE_CURRENT_SOURCE_DIR}/test_vars.in ${CMAKE_CURRENT_BINARY_DIR}/test_vars @ONLY) ``` -------------------------------- ### Windows Path Handling Source: https://github.com/libcheck/check/blob/master/tests/CMakeLists.txt Replaces forward slashes with double backslashes in the 'srcdir' variable for Windows compatibility, as test shell scripts expect platform-specific slashes. ```cmake if(WIN32) # CMake uses Unix slashes for everything, but the tests that # read srcdir expect platform specific slashes. There are two # slashes because the shell scripts will consume srcdir. string(REPLACE "/" "\\\\" srcdir "${srcdir}") set(EXEEXT ".exe") set(IS_MSVC "1") endif(WIN32) ``` -------------------------------- ### Defining No-Fork Executable Source: https://github.com/libcheck/check/blob/master/tests/CMakeLists.txt Defines the 'check_nofork' executable, listing its source file and linking it against the 'check' library. ```cmake set(CHECK_NOFORK_SOURCES check_nofork.c) add_executable(check_nofork ${CHECK_NOFORK_SOURCES}) target_link_libraries(check_nofork check) ``` -------------------------------- ### Defining Check Check Executable Source: https://github.com/libcheck/check/blob/master/tests/CMakeLists.txt Defines the 'check_check' executable, listing its source and header files, and links it against the 'check' library. ```cmake set(CHECK_CHECK_SOURCES check_check_exit.c check_check_fixture.c check_check_fork.c check_check_limit.c check_check_log.c check_check_log_internal.c check_check_main.c check_check_master.c check_check_msg.c check_check_pack.c check_check_selective.c check_check_sub.c check_check_tags.c check_list.c) set(CHECK_CHECK_HEADERS check_check.h) add_executable(check_check ${CHECK_CHECK_HEADERS} ${CHECK_CHECK_SOURCES}) target_link_libraries(check_check check) ``` -------------------------------- ### Defining No-Fork Teardown Executable Source: https://github.com/libcheck/check/blob/master/tests/CMakeLists.txt Defines the 'check_nofork_teardown' executable, specifying its source file and linking it against the 'check' library. ```cmake set(CHECK_NOFORK_TEARDOWN_SOURCES check_nofork_teardown.c) add_executable(check_nofork_teardown ${CHECK_NOFORK_TEARDOWN_SOURCES}) target_link_libraries(check_nofork_teardown check) ``` -------------------------------- ### Define Headers for libcheck Source: https://github.com/libcheck/check/blob/master/lib/CMakeLists.txt This snippet defines the header files for the libcheck compatibility library. ```cmake set(HEADERS libcompat.h) ``` -------------------------------- ### Defining Set Max Message Size Executable Source: https://github.com/libcheck/check/blob/master/tests/CMakeLists.txt Defines the 'check_set_max_msg_size' executable, listing its source file and linking it against the 'check' library. ```cmake set(CHECK_SET_MAX_MSG_SIZE_SOURCES check_set_max_msg_size.c) add_executable(check_set_max_msg_size ${CHECK_SET_MAX_MSG_SIZE_SOURCES}) target_link_libraries(check_set_max_msg_size check) ``` -------------------------------- ### Defining Check Check Export Executable Source: https://github.com/libcheck/check/blob/master/tests/CMakeLists.txt Defines the 'check_check_export' executable with its specific source and header files, and links it against the 'check' library. ```cmake set(CHECK_CHECK_EXPORT_SOURCES check_check_sub.c check_check_master.c check_check_log.c check_check_fork.c check_check_export_main.c ) set(CHECK_CHECK_EXPORT_HEADERS check_check.h) add_executable(check_check_export ${CHECK_CHECK_EXPORT_HEADERS} ${CHECK_CHECK_EXPORT_SOURCES}) target_link_libraries(check_check_export check) ``` -------------------------------- ### Set Configuration Variable Source: https://github.com/libcheck/check/blob/master/checkmk/CMakeLists.txt Sets a CMake variable for a configuration file path. Used to define input files for configuration. ```cmake set(conf_file "checkmk.in" FILEPATH) ``` -------------------------------- ### Define Man Pages Source: https://github.com/libcheck/check/blob/master/doc/man/man3/CMakeLists.txt Defines a list of man pages to be processed. This is a CMake variable assignment. ```cmake SET(MAN3_PAGES suite_create.3 ) ``` -------------------------------- ### Pthread Compiler Selection for AIX Source: https://github.com/libcheck/check/blob/master/m4/acx_pthread.html Selects the appropriate C compiler for pthreads on AIX, preferring 'xlc_r' or 'cc_r' over the default CC if not using GCC. ```shell # More AIX lossage: must compile with xlc_r or cc_r if test x"$GCC" != xyes; then AC_CHECK_PROGS(PTHREAD_CC, xlc_r cc_r, ${CC}) else PTHREAD_CC=$CC fi ``` -------------------------------- ### Add Check Library to Test Suite Source: https://github.com/libcheck/check/blob/master/tests/cmake_project_usage_test/src/CMakeLists.txt Adds a static library named 'test_suite' compiled from 'test_suite.c' and links it against the Check library using PUBLIC scope. ```cmake add_library(test_suite test_suite.c) target_link_libraries(test_suite PUBLIC Check::check) ``` -------------------------------- ### Find AWK Program Source: https://github.com/libcheck/check/blob/master/checkmk/CMakeLists.txt Searches for the 'awk' executable in the system's PATH. This is often required for build scripts that use awk for text processing. ```cmake find_program(AWK_PATH awk) ``` -------------------------------- ### Setting PTHREAD variables in Makefiles Source: https://github.com/libcheck/check/blob/master/m4/acx_pthread.html If you are building threads programs, you can use these variables in your default LIBS, CFLAGS, and CC to simplify your build process. ```shell LIBS="$PTHREAD_LIBS $LIBS" CFLAGS="$CFLAGS $PTHREAD_CFLAGS" CC="$PTHREAD_CC" ``` -------------------------------- ### Configuring Source Directory Variable Source: https://github.com/libcheck/check/blob/master/tests/CMakeLists.txt Sets the 'srcdir' variable to the current source directory, used for the test_vars.in script to provide test runners with source file locations. ```cmake set(srcdir "${CMAKE_CURRENT_SOURCE_DIR}") ``` -------------------------------- ### Configure Shared Library Properties for Windows Source: https://github.com/libcheck/check/blob/master/src/CMakeLists.txt Adjusts the output name for the shared library on Windows (MSVC) to avoid naming conflicts with static libraries. ```cmake if (MSVC) # "On Windows you should probably give each library a different name, # since there is a ".lib" file for both shared and static". # https://stackoverflow.com/a/2152157/4716395 # "Dynamic-Link Library" (DLL) is Microsoft terminology. # So we call it this: set(LIBRARY_OUTPUT_NAME "checkDynamic") endif (MSVC) ``` -------------------------------- ### Autoconf Substitution for Pthread Variables Source: https://github.com/libcheck/check/blob/master/m4/acx_pthread.html Substitutes the detected pthread related variables (LIBS, CFLAGS, CC) for use in Makefiles and other build system files. ```shell AC_SUBST(PTHREAD_LIBS) AC_SUBST(PTHREAD_CFLAGS) AC_SUBST(PTHREAD_CC) ``` -------------------------------- ### AX_CXXFLAGS_WARN_ALL_ANSI Macro Definition Source: https://github.com/libcheck/check/blob/master/m4/ax_cflags_warn_all_ansi.html Defines the autoconf macro AX_CXXFLAGS_WARN_ALL_ANSI, which is similar to AX_CFLAGS_WARN_ALL_ANSI but specifically targets C++ flags. ```m4 AC_DEFUN([AX_CXXFLAGS_WARN_ALL_ANSI],[dnl AS_VAR_PUSHDEF([FLAGS],[CXXFLAGS])dnl AS_VAR_PUSHDEF([VAR],[ac_cv_cxxflags_warn_all_ansi])dnl AC_CACHE_CHECK([m4_ifval($1,$1,FLAGS) for maximum ansi warnings], VAR,[ VAR="no, unknown" AC_LANG_SAVE AC_LANG_CPLUSPLUS ac_save_[]FLAGS="$[]FLAGS" # IRIX C compiler: # -use_readonly_const is the default for IRIX C, # puts them into .rodata, but they are copied later. # need to be "-G0 -rdatashare" for strictmode but ``` -------------------------------- ### Conditional Pthread Definition Source: https://github.com/libcheck/check/blob/master/m4/acx_pthread.html Defines HAVE_PTHREAD if POSIX threads are detected. Executes a provided action if threads are not found. ```autoconf if test x"$acx_pthread_ok" = xyes; then ifelse([$1],,AC_DEFINE(HAVE_PTHREAD,1,[Define if you have POSIX threads libraries and header files.]),[$1]) : else acx_pthread_ok=no $2 fi AC_LANG_RESTORE ``` -------------------------------- ### Autoconf Macro for ANSI C Flags Source: https://github.com/libcheck/check/blob/master/m4/ax_cflags_warn_all_ansi.html This macro iterates through a list of compiler-specific flags to test for ANSI C compliance and warning levels. It's used to determine the best set of flags for a given C compiler. ```autoconf # I am not sure what effect that has really. - guidod for ac_arg dnl in "-pedantic % -Wall -ansi -pedantic" dnl GCC "-xstrconst % -v -Xc" dnl Solaris C "-std1 % -verbose -w0 -warnprotos -std1" dnl Digital Unix " % -qlanglvl=ansi -qsrcmsg -qinfo=all:noppt:noppc:noobs:nocnd" dnl AIX " % -ansi -ansiE -fullwarn" dnl IRIX "+ESlit % +w1 -Aa" dnl HP-UX C "-Xc % -pvctl\[,\\\]fullmsg -Xc" dnl NEC SX-5 (Super-UX 10) "-h conform % -h msglevel 2 -h conform" dnl Cray C (Unicos) # do FLAGS="$ac_save_[]FLAGS "`echo $ac_arg | sed -e 's,%%.*,,' -e 's,%,,'` AC_TRY_COMPILE(\[\],\[return 0;\] \[VAR=`echo $ac_arg | sed -e 's,.*% \,,'` ; break\]) done FLAGS="$ac_save_[]FLAGS" AC_LANG_RESTORE ]) case ".$VAR" in .ok|.ok,*) m4_ifvaln($3,$3) ;; .|.no|.no,*) m4_ifvaln($4,$4,m4_ifval($2,[ AC_RUN_LOG(\[: m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $2"\]) m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $2"\n])]) ;; *) m4_ifvaln($3,$3,[ if echo " $\[\]m4_ifval($1,$1,FLAGS) " | grep " $VAR " 2>&1 >/dev/null then AC_RUN_LOG(\[: m4_ifval($1,$1,FLAGS) does contain $VAR\]) else AC_RUN_LOG(\[: m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $VAR"\]) m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $VAR" fi \]) ;; esac AS_VAR_POPDEF(\[VAR\])dnl AS_VAR_POPDEF(\[FLAGS\])dnl ]) ``` -------------------------------- ### Define ax_c_check_flag Macro Source: https://github.com/libcheck/check/blob/master/m4/ax_c_check_flag.html This is the M4 source code for the ax_c_check_flag macro. It defines the macro's functionality, including prerequisites, caching, and conditional execution based on compiler flag support. ```m4 AC_DEFUN([AX_C_CHECK_FLAG],[ AC_PREREQ([2.61]) AC_REQUIRE([AC_PROG_CC]) AC_REQUIRE([AC_PROG_SED]) flag=`echo "$1" | $SED 'y% .=/+-(){}<>:\*,% _\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_%' ` AC_CACHE_CHECK([whether the C compiler accepts the $1 flag], [ax_cv_c_check_flag_$flag],[ AC_LANG_PUSH([C]) save_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS $1" AC_COMPILE_IFELSE([ AC_LANG_PROGRAM([$2],[$3]) ],[ eval "ax_cv_c_check_flag_$flag=yes" ],[ eval "ax_cv_c_check_flag_$flag=no" ]) CFLAGS="$save_CFLAGS" AC_LANG_POP ]) AS_IF([eval "test \`echo '$ax_cv_c_check_flag_'$flag\` = yes"],[ : $4 ],[ : $5 ]) ]) ``` -------------------------------- ### AIX Joinable Pthread Attribute Detection Source: https://github.com/libcheck/check/blob/master/m4/acx_pthread.html Detects the correct name for the joinable pthread attribute on AIX, which might be PTHREAD_CREATE_JOINABLE or PTHREAD_CREATE_UNDETACHED. ```shell save_LIBS="$LIBS" LIBS="$PTHREAD_LIBS $LIBS" save_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS $PTHREAD_CFLAGS" # Detect AIX lossage: JOINABLE attribute is called UNDETACHED. AC_MSG_CHECKING([for joinable pthread attribute]) attr_name=unknown for attr in PTHREAD_CREATE_JOINABLE PTHREAD_CREATE_UNDETACHED; do AC_TRY_LINK([#include ], [int attr=$attr; return attr;], [attr_name=$attr; break]) done AC_MSG_RESULT($attr_name) if test "$attr_name" != PTHREAD_CREATE_JOINABLE; then AC_DEFINE_UNQUOTED(PTHREAD_CREATE_JOINABLE, $attr_name, [Define to necessary symbol if this constant uses a non-standard name on your system.]) fi ``` -------------------------------- ### Check and Add Pthread Compiler Flag Source: https://github.com/libcheck/check/blob/master/tests/cmake_project_usage_test/src/CMakeLists.txt Checks if the C compiler supports the '-pthread' flag and adds it to definitions and link options if supported. This is crucial for projects requiring multithreading support. ```cmake include(CheckCCompilerFlag) check_c_compiler_flag("-pthread" HAVE_PTHREAD) if (HAVE_PTHREAD) add_definitions("-pthread") add_link_options("-pthread") endif() ``` -------------------------------- ### Defining Memory Leaks Executable Source: https://github.com/libcheck/check/blob/master/tests/CMakeLists.txt Defines the 'check_mem_leaks' executable, including various source files related to logging, fixtures, and core Check functionality, and links it against the 'check' library. ```cmake set(CHECK_MEM_LEAKS_SOURCES check_mem_leaks.c check_check_log.c check_check_limit.c check_check_fixture.c check_check_fork.c check_check_exit.c check_check_selective.c check_check_sub.c check_check_master.c check_check_tags.c ) add_executable(check_mem_leaks ${CHECK_MEM_LEAKS_SOURCES}) target_link_libraries(check_mem_leaks check) ``` -------------------------------- ### Platform-Specific Pthread Reentrancy Flags Source: https://github.com/libcheck/check/blob/master/m4/acx_pthread.html Sets platform-specific preprocessor flags like -D_THREAD_SAFE or -D_REENTRANT for pthreads, depending on the operating system. ```shell AC_MSG_CHECKING([if more special flags are required for pthreads]) flag=no case "${host_cpu}-${host_os}" in *-aix* | *-freebsd* | *-darwin*) flag="-D_THREAD_SAFE";; *solaris* | *-osf* | *-hpux*) flag="-D_REENTRANT";; esac AC_MSG_RESULT(${flag}) if test "x$flag" != xno; then PTHREAD_CFLAGS="$flag $PTHREAD_CFLAGS" fi ``` -------------------------------- ### AX_CFLAGS_WARN_ALL_ANSI Macro Definition Source: https://github.com/libcheck/check/blob/master/m4/ax_cflags_warn_all_ansi.html Defines the autoconf macro AX_CFLAGS_WARN_ALL_ANSI. It checks for compiler-specific flags to enable maximum ANSI warnings and adds them to the CFLAGS variable. ```m4 AC_DEFUN([AX_CFLAGS_WARN_ALL_ANSI],[dnl AS_VAR_PUSHDEF([FLAGS],[CFLAGS])dnl AS_VAR_PUSHDEF([VAR],[ac_cv_cflags_warn_all_ansi])dnl AC_CACHE_CHECK([m4_ifval($1,$1,FLAGS) for maximum ansi warnings], VAR,[ VAR="no, unknown" AC_LANG_SAVE AC_LANG_C ac_save_[]FLAGS="$[]FLAGS" # IRIX C compiler: # -use_readonly_const is the default for IRIX C, # puts them into .rodata, but they are copied later. # need to be "-G0 -rdatashare" for strictmode but # I am not sure what effect that has really. - guidod for ac_arg dnl in "-pedantic % -Wall -ansi -pedantic" dnl GCC "-xstrconst % -v -Xc" dnl Solaris C "-std1 % -verbose -w0 -warnprotos -std1" dnl Digital Unix " % -qlanglvl=ansi -qsrcmsg -qinfo=all:noppt:noppc:noobs:nocnd" dnl AIX " % -ansi -ansiE -fullwarn" dnl IRIX "+ESlit % +w1 -Aa" dnl HP-UX C "-Xc % -pvctl[,]fullmsg -Xc" dnl NEC SX-5 (Super-UX 10) "-h conform % -h msglevel 2 -h conform" dnl Cray C (Unicos) # do FLAGS="$ac_save_[]FLAGS "`echo $ac_arg | sed -e 's,%%.*,,' -e 's,%,,'` AC_TRY_COMPILE([],[ return 0; ],[ VAR=`echo $ac_arg | sed -e 's,.*% \*,,'` ; break ]) done FLAGS="$ac_save_[]FLAGS" AC_LANG_RESTORE ]) case ".$VAR" in .ok|.ok,*) m4_ifvaln($3,$3) ;; .|.no|.no,*) m4_ifvaln($4,$4,[m4_ifval($2,[ AC_RUN_LOG([: m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $2"]) m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $2"] ) ]) ;; *) m4_ifvaln($3,$3,[ if echo " $[]m4_ifval($1,$1,FLAGS) " | grep " $VAR " 2>&1 >/dev/null then AC_RUN_LOG([: m4_ifval($1,$1,FLAGS) does contain $VAR]) else AC_RUN_LOG([: m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $VAR"]) m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $VAR" fi ]) ;; esac AS_VAR_POPDEF([VAR])dnl AS_VAR_POPDEF([FLAGS])dnl ]) ``` -------------------------------- ### Solaris Pthread Flags Configuration Source: https://github.com/libcheck/check/blob/master/m4/acx_pthread.html On Solaris, libc may contain stubbed pthreads routines. This snippet sets flags to ensure proper linking with -pthreads, -mt, and -pthread. ```shell case "${host_cpu}-${host_os}" in *solaris*) # On Solaris (at least, for some versions), libc contains stubbed # (non-functional) versions of the pthreads routines, so link-based # tests will erroneously succeed. (We need to link with -pthreads/-mt/ # -lpthread.) (The stubs are missing pthread_cleanup_push, or rather # a function called by this macro, so we could check for that, but # who knows whether they'll stub that too in a future libc.) So, # we'll just look for -pthreads and -lpthread first: acx_pthread_flags="-pthreads pthread -mt -pthread $acx_pthread_flags" ;; esac ``` -------------------------------- ### ACX_PTHREAD Macro Definition Source: https://github.com/libcheck/check/blob/master/m4/acx_pthread.html The M4 source code for the ACX_PTHREAD macro. It checks for POSIX threads support by attempting to link with various thread libraries and compiler flags. ```m4 AC_DEFUN([ACX_PTHREAD], [ AC_REQUIRE([AC_CANONICAL_HOST]) AC_LANG_SAVE AC_LANG_C acx_pthread_ok=no # We used to check for pthread.h first, but this fails if pthread.h # requires special compiler flags (e.g. on True64 or Sequent). # It gets checked for in the link test anyway. # First of all, check if the user has set any of the PTHREAD_LIBS, # etcetera environment variables, and if threads linking works using # them: if test x"$PTHREAD_LIBS$PTHREAD_CFLAGS" != x; then save_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS $PTHREAD_CFLAGS" save_LIBS="$LIBS" LIBS="$PTHREAD_LIBS $LIBS" AC_MSG_CHECKING([for pthread_join in LIBS=$PTHREAD_LIBS with CFLAGS=$PTHREAD_CFLAGS]) AC_TRY_LINK_FUNC(pthread_join, acx_pthread_ok=yes) AC_MSG_RESULT($acx_pthread_ok) if test x"$acx_pthread_ok" = xno; then PTHREAD_LIBS="" PTHREAD_CFLAGS="" fi LIBS="$save_LIBS" CFLAGS="$save_CFLAGS" fi # We must check for the threads library under a number of different # names; the ordering is very important because some systems # (e.g. DEC) have both -lpthread and -lpthreads, where one of the # libraries is broken (non-POSIX). # Create a list of thread flags to try. Items starting with a "-" are # C compiler flags, and other items are library names, except for "none" # which indicates that we try without any flags at all, and "pthread-config" # which is a program returning the flags for the Pth emulation library. acx_pthread_flags="pthreads none -Kthread -kthread lthread -pthread -pthreads -mthreads pthread --thread-safe -mt pthread-config" # The ordering *is* (sometimes) important. Some notes on the # individual items follow: # pthreads: AIX (must check this before -lpthread) # none: in case threads are in libc; should be tried before -Kthread and # other compiler flags to prevent continual compiler warnings # -Kthread: Sequent (threads in libc, but -Kthread needed for pthread.h) # -kthread: FreeBSD kernel threads (preferred to -pthread since SMP-able) # lthread: LinuxThreads port on FreeBSD (also preferred to -pthread) # -pthread: Linux/gcc (kernel threads), BSD/gcc (userland threads) # -pthreads: Solaris/gcc # -mthreads: Mingw32/gcc, Lynx/gcc # -mt: Sun Workshop C (may only link SunOS threads [-lthread], but it # doesn't hurt to check since this sometimes defines pthreads too; # also defines -D_REENTRANT) # ... -mt is also the pthreads flag for HP/aCC ]) ``` -------------------------------- ### Export Targets for Consumers Source: https://github.com/libcheck/check/blob/master/CMakeLists.txt Exports targets to be used by dependent projects. This makes your library's targets available through CMake's import system. ```cmake export(EXPORT check-targets FILE "${CMAKE_CURRENT_BINARY_DIR}/cmake/${EXPORT_NAME}-targets.cmake" NAMESPACE "${PROJECT_NAME}::" ) install(EXPORT check-targets NAMESPACE "${PROJECT_NAME}::" FILE "${EXPORT_NAME}-targets.cmake" DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${EXPORT_NAME} ) ``` -------------------------------- ### Conditional Memory Leak Test Definitions Source: https://github.com/libcheck/check/blob/master/tests/CMakeLists.txt Defines the MEMORY_LEAKING_TESTS_ENABLED macro based on the ENABLE_MEMORY_LEAKING_TESTS CMake variable. This controls whether memory leak tests are compiled in. ```cmake if(ENABLE_MEMORY_LEAKING_TESTS) add_definitions(-DMEMORY_LEAKING_TESTS_ENABLED=1) else(ENABLE_MEMORY_LEAKING_TESTS) add_definitions(-DMEMORY_LEAKING_TESTS_ENABLED=0) endif(ENABLE_MEMORY_LEAKING_TESTS) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.