A unit testing framework for CMake

Overview

CMake Unit

A unit testing framework for CMake.

Status

Travis CI (Ubuntu) AppVeyor (Windows) Coverage Biicode Licence
Travis AppVeyor Coveralls Biicode License

Why have a unit-testing framework for CMake

Because CMake is a powerful and battle-tested language for writing build systems for large-scale C++ projects, but its dynamic nature makes it easy to make undetectable errors which later ship as bugs that either you, or the users of your macros, need to work around. We have to put a lot of logic inside out CMake scripts sometimes, like propogation of global state, if conditions for various options and host system configurations and loops over variable argument lists.

It is something you want to get right the first time rather than having to scratch your head about later with the lack of debugging tools for CMake scripts.

Platforms

cmake-unit is written entirely using the CMake language and should work across all platforms where CMake is supported. It had been tested on:

  • Windows (Visual Studio 2010, 2012, 2013, NMake)
  • Mac OS X (XCode, Ninja, Make)
  • Ubuntu (Ninja, Make)

Usage

cmake-unit should be included as a submodule in your project and comes with three files.

CMakeUnitRunner

CMakeUnitRunner contains the main "runner" script for loading and executing test scripts. Include this file in the /CMakeLists.txt.

Tests are defined inline as functions. They are automatically discovered by cmake-unit and the name of the function must be in the format of ${your_namespace}_test_{test_name}. Within each test function are function definitions used to control each "phase" of the test's build. After these functions are called, a call to cmake_unit_configure_test ties all the phases functions together into a single test.

Test functions are subdivided into "phases", each phase having its own script that can be run in place of the default. Usually you will want to override the CONFIGURE or VERIFY phases in order to provide your own project set-up and verification scripts. The build of each project goes through the following phases, in order:

  • PRECONFIGURE
  • CLEAN
  • INVOKE_CONFIGURE
  • CONFIGURE
  • INVOKE_BUILD
  • INVOKE_TEST
  • VERIFY
  • COVERAGE

For each phase, a name of a function can be provided which will "override" the default function called for that phase. Some phases are called within different CMake invocations, so you shouldn't assume that state can be shared between the phase functions.

The name of each phase is a keyword argument to cmake_unit_configure_test. Following the phase name, further options can be specified for each phase. Some common options are:

  • COMMAND: The name of a function to run when this phase is encountered.
  • ALLOW_FAIL: A keyword specifying that this phase is permitted to fail (and further, that no phase after this one should be run).

The PRECONFIGURE phase

This is the first phase that is run for the test. It cannot be overridden. It does some initial setup for the test itself, including writing out a special driver script which will be used to invoke this test at CTest time.

Two options are exposed to this unit for this phase, SKIP_GENERATOR_REGEX and SKIP_SYSTEM_REGEX. A list of regular expressions can be provided for each option, which will cause the test not to run when the regex matches CMAKE_SYSTEM and CMAKE_GENERATOR respectively.

The CLEAN phase

This phase is responsible for cleaning the build directory of the test. By default, it calls cmake_unit_invoke_clean, which just removes the test project's CMAKE_BINARY_DIR.

The INVOKE_CONFIGURE phase

This phase is responsible for writing out a stub /CMakeLists.txt and jumping invoking cmake on the resulting project folder. By default it will call cmake_unit_invoke_configure. The written out /CMakeLists.txt will do some setup for the test project, including calling the project command.

cmake_unit_invoke_configure will not configure any languages by default. This is to prevent unnecessary overhead when testing on platforms where configuring language support is quite slow (for instance, Visual Studio and XCode). Instead of overriding the command, usually the only action you will need to take if you need language support is to set the LANGUAGES option (eg, to C CXX).

The CONFIGURE phase

This phase is responsible for actually configuring the project. Any commands run inside this phase are effectively run as though CMake was configuring a project by processing a /CMakeLists.txt, so the full range of commands are available. Usually you will want to override the COMMAND and configure your project as required (or make assertions).

The INVOKE_BUILD phase

This phase is responsible for invoking cmake --build. Usually the COMMAND will not need to be overridden, but if the build can fail or if the project should not be built at all, then ALLOW_FAIL or COMMAND NONE should be specified respectively.

The TARGET option allows you to specify a custom target to build instead of the default one.

The INVOKE_TEST phase

This phase is responsible for invoking ctest. Usually the COMMAND will not need to be overridden, unless you need to invoke ctestin a special way.

The VERIFY phase

This phase is responsible for verifying that the configure, build and test steps went the way you expected. It is executed after the final step of the configure-build-test cycle is completed for this project.

You can inspect the standard output and error of each of these steps. Use the cmake_unit_get_log_for command in order to fetch the path to these log files.

The COVERAGE phase

This phase is responsible for collecting tracefile output and turning it into line-coverage statistics. It is not overridable.

An example of a test

Here is an example of how a test looks in practice:

function (namespace_test_one)

    function (_namespace_configure)

        cmake_unit_create_simple_library (library SHARED FUNCTIONS function)
        cmake_unit_create_simple_executable (executable)
        target_link_libraries (executable library)

        cmake_unit_assert_that (executable is_linked_to library)

    endfunction ()

    function (_namespace_verify)

        cmake_unit_get_log_for (INVOKE_BUILD OUTPUT BUILD_OUTPUT)

        cmake_unit_assert_that ("${BUILD_OUTPUT}"
                                file_contents any_line
                                matches_regex
                                "^.*executable.*$")

    endfunction ()

    cmake_unit_configure_test (INVOKE_CONFIGURE LANGUAGES C CXX
                               CONFIGURE COMMAND _namespace_configure
                               VERIFY COMMAND _namespace_verify)

endfunction ()

The _namespace_configure and _namespace_verify functions are defined within the namespace_test_one function. They are passed to the COMMAND keyword for the CONFIGURE and VERIFY phases on cmake_unit_configure_test.

LANGUAGES C CXX is passed to INVOKE_CONFIGURE. This ensures that compilers are tested and CMake is set up to build and link C and C++ binary code.

Shortcut to skip the build phase

If there's no need to build and test the test project, or to verify it, you can use cmake_unit_configure_config_only_test in place of cmake_unit_configure_test. This will pass INVOKE_BUILD COMMAND NONE and INVOKE_TEST COMMAND NONE to cmake_unit_configure_test along with whatever options you specify.

Discovering tests and running them

cmake_unit_init is what handles the registration and running of each discovered test function. It takes a namespace as the argument to the keyword NAMESPACE. This is the name each test is prefixed with (followed by _test). Any function matching the pattern ^${namespace}test.*$ will be automatically registered. It also takes a list of files considered to be candidates for code coverage as COVERAGE_FILES.

As an example, see the following:

cmake_unit_init (NAMESPACE namespace
                 COVERAGE_FILES "${PROJECT_DIR}/Module.cmake")

CMakeUnit

CMakeUnit contains matchers and a general cmake_unit_assert_that function. You can use them in both the configure and verify stages. If the script hits an assertion failure, it will call message (SEND_ERROR).

Built-in matchers

The following matchers are available at the time of writing this documentation

  • is_true: Matches if the passed variable name has a value that is boolean true.
  • is_false: Matches if the passed variable name has a value that is boolean false.
  • target_exists: Matches if the target provided as the first argument exists.
  • variable_contains: Matches if a substring is present in the value of the value of the variable name.
  • compare_as: Matches if the variable specified satisfies the parameters provided. A variable name, type, comparator statement (EQUAL LESS GREATER) and value to compare against can be provided.
  • matches_regex: Matches if the value of the variable provided, when treated as a string matches the regex provided in the second argument.
  • is_defined: Matches any variable that is defined
  • executes_with_success: For a command and each of its arguments encapsulated in the list passed-by-variable-name (as opposed to by value), check if it executed with success.
  • is_linked_to: Matches if the target has a link library that matches the name specified by the second argument. It does regex matching to ensure that in the default case, libraries with slightly inexact names between platforms are still matched against.
  • list_contains_value: Checks inside specified variable name containing a list to see if any item contains a value satisfying the criteria.
  • has_property_with_value: Matches if the item specified with the item type specified has property with a value and type specified which matches the provided comparator.
  • has_property_containing_value: Like has_property_with_value but looks inside items in a list held by the property.
  • exists_as_file: Matches if file exists on the filesystem.
  • file_contents: Matches if the contents of a file match the matcher and arguments provided afterwards.
  • any_line: Matches if any line of a multi-line string matches the following matcher and its arguments.
  • not: Matches if the item specified does not match the following matcher.

Writing your own matchers

cmake-unit can be extended with your own matchers. To do this, you will need to write a "callable" function in your project's namespace, for example

function (my_namespace_equal_to_seven)

    list (GET CALLER_ARGN 0 VARIABLE)
    list (GET CALLER_ARGN -1 RESULT_VALUE)

    set (${RESULT_VALUE} "to be equal to 7" PARENT_SCOPE)

    if ("${${VARIABLE}}" EQUAL 7)

        set (${RESULT_VALUE} TRUE PARENT_SCOPE)

    endif ()

endfunction ()

Then you will need to register your project's namespace as a namespace containing matchers

cmake_unit_register_matcher_namespace (my_namespace)

You can start using your matcher like so:

cmake_unit_assert_that (VARIABLE equal_to_seven)

The function my_namespace_equal_to_seven is a callable function abiding by the calling convention set out below. Its first argument will always be the variable-to-be-matched. Depending on what your matcher does, this may be a value or a variable name. The last variable is always the "result variable", which is the name of the variable that you will need to set in the parent scope to indicate the matcher status. By convention, matchers should set this variable to a sentence fragment that would provide a sensible explanation of what happened in the sentence "Expected VARIABLE ..." in case there was a mismatch. Otherwise, the variable should be set to TRUE.

Overridable Phase Functions

Each of these functions is a default for a phase of a cmake-unit test's build cycle. If they are overridden, they can be "chained up" to. CALLER_ARGN will be passed implicitly.

cmake_unit_invoke_clean

Cleans the project BINARY_DIRECTORY (as specified in CALLER_ARGN).

cmake_unit_invoke_configure

Creates a /CMakeLists.txt for this project which does some initial setup and then jumps to the function defined for CONFIGURE. cmake is invoked on a build directory for the folder containing the created /CMakeLists.txt.

cmake_unit_invoke_build

Invokes cmake --build on this project.

cmake_unit_invoke_test

Invokes ctest -C Debug on this project.

Utility Functions

cmake-unit also provides a few utility functions to make writing tests easier.

Strings
cmake_unit_escape_string

Escape all characters from INPUT and store in OUTPUT_VARIABLE

Test data
cmake_unit_get_dirs

Reliably returns the binary and source directories for this test. You should use this instead of CMAKE_CURRENT_SOURCE_DIR and CMAKE_CURRENT_BINARY_DIR where possible, as it will be correct in every phase.

Source File Generation
cmake_unit_create_source_file_before_build

Writes out a source file, for use with add_library, add_executable or source scanners during the configure phase.

If the source is detected as a header based on the NAME property such that it does not have a C or C++ extension, then header guards will be written and function definitions will not be included.

  • [Optional] NAME: Name of the source file. May include slashes which will be interpreted as a subdirectory relative to CMAKE_CURRENT_SOURCE_DIR. The default is Source.cpp
  • [Optional] FUNCTIONS_EXPORT_TARGET: The target that this source file is built for. Generally this is used if it is necessary to export functions from this source file. cmake_unit_create_simple_library uses this argument for instance.
  • [Optional] INCLUDES: A list of files, relative or absolute paths, to #include
  • [Optional] DEFINES: A list of #defines (macro name only)
  • [Optional] FUNCTIONS: A list of functions.
  • [Optional] PREPEND_CONTENTS: Contents to include in the file after INCLUDES, DEFINES and Function Declarations, but before Function Definitions
  • [Optional] INCLUDE_DIRECTORIES: A list of directories such that, if an entry in the INCLUDES list has the same directory name as an entry in INCLUDE_DIRECTORIES then the entry will be angle-brackets <include> with the path relative to that include directory.
cmake_unit_generate_source_file_during_build

Generates a source file, for use with add_library, add_executable or source scanners during the build phase.

If the source is detected as a header based on the NAME property such that it does not have a C or C++ extension, then header guards will be written and function definitions will not be included.

  • TARGET_RETURN: Variable to store the name of the target this source file will be generated on
  • [Optional] NAME: Name of the source file. May include slashes which will be interpreted as a subdirectory relative to CMAKE_CURRENT_SOURCE_DIR. The default is Source.cpp
  • [Optional] FUNCTIONS_EXPORT_TARGET: The target that this source file is built for. Generally this is used if it is necessary to export functions from this source file. cmake_unit_create_simple_library uses this argument for instance.
  • [Optional] INCLUDES: A list of files, relative or absolute paths, to #include
  • [Optional] DEFINES: A list of #defines (macro name only)
  • [Optional] FUNCTIONS: A list of functions.
  • [Optional] PREPEND_CONTENTS: Contents to include in the file after INCLUDES, DEFINES and Function Declarations, but before Function Definitions
  • [Optional] INCLUDE_DIRECTORIES: A list of directories such that, if an entry in the INCLUDES list has the same directory name as an entry in INCLUDE_DIRECTORIES then the entry will be angle-brackets <include> with the path relative to that include directory.
Binary target generation

These functions can be used to generate binary targets such as simple executables and libraries. There will only be a single source file per executable or library generated.

cmake_unit_create_simple_executable

Creates a simple executable by the name "NAME" which will always have a "main" function.

  • NAME: Name of executable
  • [Optional] INCLUDES: A list of files, relative or absolute paths, to #include
  • [Optional] DEFINES: A list of #defines (macro name only)
  • [Optional] FUNCTIONS: A list of functions.
  • [Optional] PREPEND_CONTENTS: Contents to include in the file after INCLUDES, DEFINES and Function Declarations, but before Function Definitions
  • [Optional] INCLUDE_DIRECTORIES: A list of directories such that, if an entry in the INCLUDES list has the same directory name as an entry in INCLUDE_DIRECTORIES then the entry will be angle-brackets <include> with the path relative to that include directory.
cmake_unit_create_simple_library

Creates a simple executable by the name "NAME" which will always have a "main" function.

  • NAME: Name of executable
  • [Optional] INCLUDES: A list of files, relative or absolute paths, to #include
  • [Optional] DEFINES: A list of #defines (macro name only)
  • [Optional] FUNCTIONS: A list of functions.
  • [Optional] PREPEND_CONTENTS: Contents to include in the file after INCLUDES, DEFINES and Function Declarations, but before Function Definitions
  • [Optional] INCLUDE_DIRECTORIES: A list of directories such that, if an entry in the INCLUDES list has the same directory name as an entry in INCLUDE_DIRECTORIES then the entry will be angle-brackets <include> with the path relative to that include directory.
Working with Built Projects
cmake_unit_get_target_location_from_exports

For an exports file EXPORTS and target TARGET, finds the location of a target from an already generated EXPORTS file.

This function should be run in the verify stage in order to determine the location of a binary or library built by CMake. The initial configure step should run export (TARGETS ...) in order to generate this file.

This function should always be used where a binary or library needs to be invoked after build. Different platforms put the completed binaries in different places and also give them a different name. This function will resolve all those issues.

  • EXPORTS: Full path to EXPORTS file to read
  • TARGET: Name of TARGET as it will be found in the EXPORTS file
  • LOCATION_RETURN: Variable to write target's LOCATION property into.
cmake_unit_export_cfg_int_dir

Exports the current CMAKE_CFG_INTDIR variable (known at configure-time) and writes it into the file specified at LOCATION. This file could be read after the build to determine the CMAKE_CFG_INTDIR property

  • LOCATION: Filename to write CMAKE_CFG_INTDIR variable to.
cmake_unit_import_cfg_int_dir

Reads OUTPUT_FILE to import the value of the CMAKE_CFG_INTDIR property and stores the value inside of LOCATION_RETURN. This should be run in the verify phase to get the CMAKE_CFG_INTDIR property for the configure phase generator. Use cmake_unit_export_cfg_int_dir in the configure phase to export the CMAKE_CFG_INTDIR property.

  • OUTPUT_FILE: Filename to read CMAKE_CFG_INTDIR variable from.
  • LOCATION_RETURN: Variable to store CMAKE_CFG_INTDIR value into.
cmake_unit_get_log_for

Gets the LOG_TYPE log for PHASE and stores it in the variable specified in LOG_FILE_RETURN. The returned log is a path to a file. Valid values for the LOG_TYPE parameter are ERROR and OUTPUT.

CMakeTraceToLCov

CMakeTraceToLCov is a script that converts a tracefile generated by using CMAKE_UNIT_LOG_COVERAGE=ON into a Linux Test Project Coverage (LCov) compatible file.

CMakeTraceToLCov should be run in script mode from the toplevel source directory where CMake scripts are to be kept.

There are two cache options which must be set prior to use:

  • TRACEFILE: Path to a tracefile generated by using CMAKE_UNIT_LOG_COVERAGE=ON
  • LCOV_OUTPUT: Path to filename where LCov output file should be stored.

Known Issues

The following issues are known at the time of writing:

  • polysquare/cmake-unit#55 : Custom Command output on Visual Studio Generators not available
  • polysquare/cmake-unit#56 : cmake-unit overrides add_custom_command
  • polysquare/cmake-unit#57 : Coverage file paths may not contain square brackets ([])

Technical Implementation Notes

cmake-unit uses some clever hacks under the hood in order to achieve its "streamlined" test definition syntax.

Calling arbitrary functions

Test auto-discovery, dynamic test loading and custom phase specification is all achieved through the ability to call arbitrary functions. CMake doesn't offer any syntax to do so, but there is a back door using a debugging feature called variable_watch.

Obviously, variable_watch provides its own arguments to the called function, which is not entirely what we want. However, CMake makes it relatively easy to establish a kind of "calling convention" for these called functions. Usage of keyword arguments with CMakeParseArguments is pretty common for most modules. We defined a variable called CALLER_ARGN which functions just like ARGN would in a normal function call. All arguments are passed as keywords.

variable_watch can only be used to register a callback for one variable at a time, so if a function is to be called multiple times, then a register needs to be maintained mapping function names to variable names.

All of this is encapsulated within the cmake_call_function command. This is hosted as a separate block on biicode. It is hoped that eventually this can become part of the core CMake syntax.

Discovering test functions

Test function discovery is by using the "hidden" COMMANDS property of GLOBAL scope. This provides a list of all defined commands at the time of retrieving the property.

Comments
  • A rewrite of cmake-unit.

    A rewrite of cmake-unit.

    All tests are now inlined in the CMakeLists.txt file. They are automatically discovered and called dynamically. Tests are discovered based on function names. A test will be added if it starts with the namespace name passed to cmake_unit_init followed by "test".

    Inside each test are subfunctions which allow custom code to be executed on each stage of the build process. The names of these functions are then passed as values after the COMMAND to the phase keywords for cmake_unit_configure_test.

    Those phases are:

    -> CLEAN: Clean the build. -> INVOKE_CONFIGURE: Invoke the initial configuration of the build (but not the actual configuration script itself) -> CONFIGURE: The configure script itself. -> INVOKE_BUILD: Invoke the build of the project. -> INVOKE_TEST: Invoke testing of the project. -> VERIFY: The verify script, to be run after the project is configured, built and tested.

    By default, all tests will have no language configured. This speeds up the project configure/build/test cycle substantially on generators where initializing language support is very slow (Visual Studio, XCode). However, it means that adding C or C++ executables inside of configure scripts will not be supported. In order to enable support for this, LANGUAGES should be specified after the INVOKE_CONFIGURE keyword for cmake_unit_configure_test.

    Registering and running tests is a two-step process. First tests should be discovered using cmake_unit_discover_tests and then the discovered tests should be passed to the TESTS keyword for cmake_unit_init.

    opened by smspillaz 17
  • Fix coverage reporting on Windows

    Fix coverage reporting on Windows

    Warnings were getting caught up in the coverage script on Windows. This was causing the coverage script to fail due to extraneous lines being present.

    Also fixed a small typo which caused the coverage trace lines to be truncated at drive letters on Windows.

    Finally, updated appveyor.yml and .travis.yml to ensure that these parts are tested.

    Cache the CMake installer download on AppVeyor.

    opened by smspillaz 16
  • Make warnings fatal and fix tracing on Windows

    Make warnings fatal and fix tracing on Windows

    Warnings were getting caught up in the coverage script on Windows. This was causing the coverage script to fail due to extraneous lines being present.

    Also fixed a small typo which caused the coverage trace lines to be truncated at drive letters on Windows.

    Finally, updated appveyor.yml and .travis.yml to ensure that these parts are tested.

    Cache the CMake installer download on AppVeyor.

    opened by smspillaz 14
  • Fix tracing problems on Windows

    Fix tracing problems on Windows

    Warnings mess up the coverage recording process and scripts generally shouldn't have them. If this is a problem for testing existing scripts, they can be disabled by passing CMAKE_UNIT_NO_DEV_WARNINGS=TRUE or CMAKE_UNIT_NO_UNIITIALIZED_WARNINGS=TRUE

    Added test coverage for past VS versions.

    Fix slow builds on Windows.

    Fix early truncation on Windows.

    opened by smspillaz 4
  • Improve test verbose output.

    Improve test verbose output.

    Each line of the output string is now tagged with its corresponding step and whether or not it is OUTPUT or ERROR.

    In addition, coverage tracefile lines are now filtered out of the configure error output. Just warnings and errors are shown.

    opened by smspillaz 3
  • Cache the results of cmake_parse_arguments where appropriate.

    Cache the results of cmake_parse_arguments where appropriate.

    There were some cases where cmake_parse_arguments was being called with the same arguments hundreds of times. These are easy candidates for a cache table. This should reduce test runtime by about 20-30%.

    opened by smspillaz 2
  • Add convenience functions to generate source files and simple binaries

    Add convenience functions to generate source files and simple binaries

    Use cmake_unit_create_source_file_before_build to generate a source file during the configure phase. A NAME for the source file can be passed in as well as a list of INCLUDES, DEFINES and FUNCTIONS. Custom contents can be added using PREPEND_CONTENTS.

    Use cmake_unit_generate_source_file_during_build to generate a source file in the build phase. This function takes similar arguments to cmake_unit_create_source_file_before_build.

    Use cmake_unit_create_simple_executable to create a simple executable with the name NAME that just returns 0.

    Use cmake_unit_create_simple_library with the name NAME and some specified FUNCTIONS to create a simple library that has those functions. The functions will be exported automatically.

    If you need to get the full path to a compiled library or executable in the verify phase, then use export (TARGETS ${TARGET}) in the configure phase and then use cmake_unit_get_target_location_from_exports specifying the location of the EXPORTS file in the build-directory and the name of the target to look up.

    opened by smspillaz 2
  • Adjust the last close bracket index as opposed to the line length.

    Adjust the last close bracket index as opposed to the line length.

    This prevents the case where the last "close bracket" was being found on empty lines, because they would have a length of -1 (which was also the postion of the close bracket if it were not found on that line)

    opened by smspillaz 2
  • Generate coverage reports of CMake-Unit tests

    Generate coverage reports of CMake-Unit tests

    CMake Unit can now generate a coverage report of all running tests. In order to do this, the test author should put each file they wish to have reported as part of the coverage report in the list COVERAGE_FILES passed to bootstrap_cmake_unit. The coverage report only covers lines (CMake's trace mode provides us with enough information to determine branches and function calls and support may be added in future versions)

    Set CMAKE_UNIT_LOG_COVERAGE to ON to enable "trace" logging. This will cause relevant output of CMake's trace mode to be logged to ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_PROJECT_NAME}.trace.

    This file format isn't particularly useful, so a tool to convert this data into Linux Test Project Coverage (LCov) is available by running CMakeTraceToLCov with the following variables specified:

    • TRACEFILE: Path to a tracefile generated by CMAKE_UNIT_LOG_COVERAGE
    • LCOV_OUTPUT: Path to lcov output file.
    opened by smspillaz 2
  • Some optimizations that substantially reduce test runtime.

    Some optimizations that substantially reduce test runtime.

    We spent a substantial amount of time computing test lists and dispatch tables. This ocurred multiple times every single time CMakeLists.txt was re-entered and was effectively redundant work as the value would be the same every time. Cache the values of these lists and tables as global properties and pass them to each CMake invocation.

    Removed cmake_unit_discover_tests and instead folded test detection in a namespace into the NAMESPACE keyword of cmake_unit_init. Given that we can dynamically look up command names at runtime, there isn't much need for a separate function in the API to discover tests anymore.

    opened by smspillaz 1
  • Depart from the convention of repeating conditions, function names etc.

    Depart from the convention of repeating conditions, function names etc.

    The previous convention was to put this information in else (), endmacro (), endif (), endfunction () etc blocks. This was bad practice.

    Remove all instances of this and make cmakelint catch any new instances of it.

    opened by smspillaz 1
  • I have trouble with getting cmake-unit and dependencies.

    I have trouble with getting cmake-unit and dependencies.

    Hi smspillaz,

    I would like to try out the cmake-unit project, but I have trouble "installing" it. When I download the project and simply add it to my project it misses the file conanbuildinfo.cmake. It would be very helpful if you had some instructions on how to correctly get your package and its dependencies at the top of the documentation.

    From the conan.py file, I take that the missing files are retrieved using the conan package manager. I have only beginners knowledge of python and none of conan. I am working with python 3.4 on windows btw. So this is what I tried so far:

    • install conan with python -m pip install conan
    • add the conan directory to PYTHONPATH
    • changed the current directory to the download directory of cmake-unit which I copied into my project.
    • ran python -m conan install -> retrieved the following error output
    Requirements
        cmake-call-function/master@smspillaz/cmake-call-function from conan.io
        cmake-forward-arguments/master@smspillaz/cmake-forward-arguments from conan.io
        cmake-forward-cache/master@smspillaz/cmake-forward-cache from conan.io
        cmake-include-guard/master@smspillaz/cmake-include-guard from conan.io
        cmake-opt-arg-parsing/master@smspillaz/cmake-opt-arg-parsing from conan.io
        cmake-spacify-list/master@smspillaz/cmake-spacify-list from conan.io
    Packages
        cmake-call-function/master@smspillaz/cmake-call-function:c6adec7915b5bae7abf89c59546b0a540bfb7601
        cmake-forward-arguments/master@smspillaz/cmake-forward-arguments:c6adec7915b5bae7abf89c59546b0a540bfb7601
        cmake-forward-cache/master@smspillaz/cmake-forward-cache:c6adec7915b5bae7abf89c59546b0a540bfb7601
        cmake-include-guard/master@smspillaz/cmake-include-guard:5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9
        cmake-opt-arg-parsing/master@smspillaz/cmake-opt-arg-parsing:c6adec7915b5bae7abf89c59546b0a540bfb7601
        cmake-spacify-list/master@smspillaz/cmake-spacify-list:34a1ee842030afb1f43dc95a615b35ab928736f2
    
    WARN: Can't find a 'cmake-include-guard/master@smspillaz/cmake-include-guard' package for the specified options and settings:
    - Settings:
    - Options: dev=False
    
    ERROR: Missing prebuilt package for 'cmake-include-guard/master@smspillaz/cmake-include-guard'
    Try to build it from sources with "--build cmake-include-guard"
    Or read "http://docs.conan.io/en/latest/faq/troubleshooting.html#error-missing-prebuilt-package"
    
    • threw my hands up in desperation, gave up and wrote this issue ;-)

    Do you have any ideas what else do I need to do to make it work? Thank you for your time.

    opened by Knitschi 3
  • Coverage file paths may not contain square brackets ([])

    Coverage file paths may not contain square brackets ([])

    Coverage file paths may not contain the square brackets ([,]) characters. These characters are stripped out of the configure phase standard error as they cause problems with ; delimiters splitting lines in CMake.

    Workaround: Do not use square brackets in filenames or paths to filenames.

    wontfix 
    opened by smspillaz 0
  • cmake-unit overrides add_custom_command

    cmake-unit overrides add_custom_command

    cmake-unit overrides add_custom_command so that it can print command names for generators in a workaround #55. This is known to be somewhat unreliable and prevents any client code from overriding add_custom_command too because CMake only stores one override entry in its function table.

    Workaround: client code may not define any function named add_custom_command.

    wontfix 
    opened by smspillaz 0
  • Custom Command output on Visual Studio Generators not available

    Custom Command output on Visual Studio Generators not available

    The command name add_custom_target on Visual Studio generators will never be printed in the build logs, even with the highest verbosity settings. This makes it impossible to check the build logs to see if commands ran.

    A similar issue theoretically exists for add_custom_command, but this can be worked around.

    Workaround: Avoid running commands in add_custom_target. Instead, generate a file and use add_custom_command instead.

    wontfix 
    opened by smspillaz 0
Owner
ポリ平方 POLYSQUARE
ポリ平方 POLYSQUARE
CMake checks cache helper modules – for fast CI CMake builds!

cmake-checks-cache Cross platform CMake projects do platform introspection by the means of "Check" macros. Have a look at CMake's How To Write Platfor

Cristian Adam 65 Dec 6, 2022
CMake scripts for painless usage of SuiteSparse+METIS from Visual Studio and the rest of Windows/Linux/OSX IDEs supported by CMake

CMake scripts for painless usage of Tim Davis' SuiteSparse (CHOLMOD,UMFPACK,AMD,LDL,SPQR,...) and METIS from Visual Studio and the rest of Windows/Lin

Jose Luis Blanco-Claraco 395 Dec 24, 2022
cmake-font-lock - Advanced, type aware, highlight support for CMake

cmake-font-lock - Advanced, type aware, highlight support for CMake

Anders Lindgren 39 Oct 2, 2022
cmake-avr - a cmake toolchain for AVR projects

cmake-avr - a cmake toolchain for AVR projects Testing the example provided The toolchain was created and tested within the following environment: Lin

Matthias Kleemann 163 Dec 5, 2022
Make CMake less painful when trying to write Modern Flexible CMake

Izzy's eXtension Modules IXM is a CMake library for writing Modern flexible CMake. This means: Reducing the amount of CMake written Selecting reasonab

IXM 107 Sep 1, 2022
CMake module to enable code coverage easily and generate coverage reports with CMake targets.

CMake-codecov CMake module to enable code coverage easily and generate coverage reports with CMake targets. Include into your project To use Findcodec

HPC 82 Nov 30, 2022
unmaintained - CMake module to activate certain C++ standard, feature checks and appropriate automated workarounds - basically an improved version of cmake-compile-features

Compatibility This library provides an advanced target_compile_features() and write_compiler_detection_header(). The problem with those is that they a

Jonathan Müller 74 Dec 26, 2022
[CMake] [BSD-2] CMake module to find ICU

FindICU.cmake A CMake module to find International Components for Unicode (ICU) Library Note that CMake, since its version 3.7.0, includes a FindICU m

julp 29 Nov 2, 2022
CMake project for BL602 RISC-V processor

bl602_cmake_base CMake project for BL602 RISC-V processor How to build NOTE : This project uses a pre-compiled version of the Buffalo SDK (bl_iot_sdk)

null 9 Jan 6, 2022
A CMake toolchain file for iOS, macOS, watchOS & tvOS C/C++/Obj-C++ development

A CMake toolchain file for iOS, macOS, watchOS & tvOS C/C++/Obj-C++ development

Alexander Widerberg 1.4k Jan 4, 2023
curl cmake module libcurl build with msvc x86

curl-msvc Infomation curl cmake module libcurl build with MSVC10.0 arch (x86 | i386) source from https://github.com/curl/curl tags: curl-7_79_1 Usage

Jason Payne 0 May 16, 2022
NeoWorld is a resampler using the CMake build system

NeoWorld is a resampler using the CMake build system. It's designed for utsu, OpenUTAU, and UTAU.

null 5 Dec 23, 2022
A CMake addon that avoids you writing boilerplate code for resource management.

SHader INJ(I)ector SHINJI (originally SHader INJector) is a CMake addon that avoids you writing boilerplate code for resource management and exposes s

Lorenzo Rutayisire 6 Dec 14, 2022
A CMake starter template using CPM

Cmake Starter About A lightweight Cmake project meant for a binary application (not a shared library), tests with catch2 are configured, CPM is the pa

Matt Williams 1 Jul 14, 2022
Non-intrusive CMake dependency management

cmodule Non-intrusive CMake dependency management. Normally CMake's find_package() looks for packages installed on host system (and compiled for host

scapix.com 14 Sep 29, 2022
Simple library for embedding static resources into C++ binaries using CMake

libromfs libromfs is an easy way to bundle resources directly into any C++ application and access them through a simple interface. The main advantage

WerWolv 28 Nov 30, 2022
Project to enable using CMake from a Maven build.

CMake-Maven-Project Introduction A Maven project for the CMake build system. It can be used by including it as a plugin within your Maven project's po

null 60 Nov 14, 2022
Autotools-style configure script wrapper around CMake

configure-cmake configure-cmake is an autotools-style configure script for CMake-based projects. People building software on Linux or BSD generally ex

Evan Nemerson 82 Dec 14, 2022
Check for coding style issues in CMake files

cmakelint parses CMake files and reports style issues. cmakelint requires Python. Installation sudo pip install cmakelint Usage Syntax: cmakelint [--c

Richard Quirk 99 Dec 10, 2022