Reorganize repository

* Move the project top-level CMakeLists.txt to the root of the project;
  this allows building Cyclone as part of ROS2 without any special
  tricks;

* Clean up the build options:

  ENABLE_SSL:    whether to check for and include OpenSSL support if a
                 library can be found (default = ON); this used to be
                 called DDSC_ENABLE_OPENSSL, the old name is deprecated
                 but still works
  BUILD_DOCS:    whether to build docs (default = OFF)
  BUILD_TESTING: whether to build test (default = OFF)

* Collect all documentation into top-level "docs" directory;

* Move the examples to the top-level directory;

* Remove the unused and somewhat misleading pseudo-default
  cyclonedds.xml;

* Remove unused cmake files

Signed-off-by: Erik Boasson <eb@ilities.com>
This commit is contained in:
Erik Boasson 2019-07-26 09:43:53 +02:00 committed by eboasson
parent 4e80559763
commit 9cf4b97f1a
102 changed files with 627 additions and 1925 deletions

View file

@ -0,0 +1,65 @@
#
# Copyright(c) 2006 to 2018 ADLINK Technology Limited and others
#
# This program and the accompanying materials are made available under the
# terms of the Eclipse Public License v. 2.0 which is available at
# http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
# v. 1.0 which is available at
# http://www.eclipse.org/org/documents/edl-v10.php.
#
# SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
#
cmake_minimum_required(VERSION 3.3) # For IN_LIST
option(ANALYZE_BUILD "Enable static analysis during build" OFF)
if(ANALYZE_BUILD)
get_property(languages GLOBAL PROPERTY ENABLED_LANGUAGES)
set(scan_build_supported Clang AppleClang GNU)
if("C" IN_LIST languages)
include(CheckCCompilerFlag)
if(CMAKE_C_COMPILER_ID STREQUAL "MSVC")
set(ANALYZE_C_BUILD_FLAG "/analyze")
elseif(CMAKE_C_COMPILER_ID IN_LIST scan_build_supported)
message(STATUS "Static analysis for C using ${CMAKE_C_COMPILER_ID}-compiler is available by using 'scan-build' manually only")
endif()
if(CMAKE_C_COMPILER_ID STREQUAL "MSVC")
CHECK_C_COMPILER_FLAG(${ANALYZE_C_BUILD_FLAG} C_COMPILER_HAS_ANALYZE_BUILD)
if(C_COMPILER_HAS_ANALYZE_BUILD)
if(CMAKE_GENERATOR MATCHES "Visual Studio")
# $<COMPILE_LANGUAGE:...> may not be used with Visual Studio generators.
add_compile_options(${ANALYZE_C_BUILD_FLAG})
else()
add_compile_options($<$<COMPILE_LANGUAGE:C>:${ANALYZE_C_BUILD_FLAG}>)
endif()
endif()
endif()
endif()
if("CXX" IN_LIST languages)
include(CheckCXXCompilerFlag)
if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
set(ANALYZE_CXX_BUILD_FLAG "/analyze")
elseif(CMAKE_C_COMPILER_ID IN_LIST scan_build_supported)
message(STATUS "Static analysis for CXX using ${CMAKE_CXX_COMPILER_ID}-compiler is available by using 'scan-build' manually only")
endif()
if(DEFINED ANALYZE_CXX_BUILD_FLAG)
CHECK_CXX_COMPILER_FLAG(${ANALYZE_CXX_BUILD_FLAG} CXX_COMPILER_HAS_ANALYZE_BUILD)
if(CXX_COMPILER_HAS_ANALYZE_BUILD)
if(CMAKE_GENERATOR MATCHES "Visual Studio")
add_compile_options(${ANALYZE_CXX_BUILD_FLAG})
else()
add_compile_options($<$<COMPILE_LANGUAGE:CXX>:${ANALYZE_CXX_BUILD_FLAG}>)
endif()
endif()
endif()
endif()
endif()

311
cmake/Modules/CUnit.cmake Normal file
View file

@ -0,0 +1,311 @@
#
# Copyright(c) 2006 to 2018 ADLINK Technology Limited and others
#
# This program and the accompanying materials are made available under the
# terms of the Eclipse Public License v. 2.0 which is available at
# http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
# v. 1.0 which is available at
# http://www.eclipse.org/org/documents/edl-v10.php.
#
# SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
#
find_package(CUnit REQUIRED)
set(CUNIT_DIR "${CMAKE_CURRENT_LIST_DIR}/CUnit")
function(get_cunit_header_file SOURCE_FILE HEADER_FILE)
# Return a unique (but consistent) filename where Theory macros can be
# written. The path that will be returned is the location to a header file
# located in the same relative directory, using the basename of the source
# file postfixed with .h. e.g. <project>/foo/bar.h would be converted to
# <project>/build/foo/bar.h.
get_filename_component(SOURCE_FILE "${SOURCE_FILE}" ABSOLUTE)
file(RELATIVE_PATH SOURCE_FILE "${PROJECT_SOURCE_DIR}" "${SOURCE_FILE}")
get_filename_component(basename "${SOURCE_FILE}" NAME_WE)
get_filename_component(dir "${SOURCE_FILE}" DIRECTORY)
set(${HEADER_FILE} "${CMAKE_BINARY_DIR}/${dir}/${basename}.h" PARENT_SCOPE)
endfunction()
function(parse_cunit_fixtures INPUT TEST_DISABLED TEST_TIMEOUT)
if(INPUT MATCHES ".disabled${s}*=${s}*([tT][rR][uU][eE]|[0-9]+)")
set(${TEST_DISABLED} "TRUE" PARENT_SCOPE)
else()
set(${TEST_DISABLED} "FALSE" PARENT_SCOPE)
endif()
if(INPUT MATCHES ".timeout${s}*=${s}*([0-9]+)")
set(${TEST_TIMEOUT} "${CMAKE_MATCH_1}" PARENT_SCOPE)
else()
set(${TEST_TIMEOUT} "0" PARENT_SCOPE)
endif()
endfunction()
# Parse a single source file, generate a header file with theory definitions
# (if applicable) and return suite and test definitions.
function(process_cunit_source_file SOURCE_FILE HEADER_FILE SUITES TESTS)
set(x "\\*")
set(s "[ \t\r\n]")
set(s_or_x "[ \t\r\n\\*]")
set(w "[_a-zA-Z0-9]")
set(ident_expr "(${s}*${w}+${s}*)")
# Very basic type recognition, only things that contain word characters and
# pointers are handled. And since this script does not actually have to
# compile any code, type checking is left to the compiler. An error (or
# warning) will be thrown if something is off.
#
# The "type" regular expression below will match things like:
# - <word> <word>
# - <word> *<word>
# - <word>* <word> *<word>
set(type_expr "(${s}*${w}+${x}*${s}+${s_or_x}*)+")
set(param_expr "${type_expr}${ident_expr}")
# Test fixture support (based on test fixtures as implemented in Criterion),
# to enable per-test (de)initializers, which is very different from
# per-suite (de)initializers, and timeouts.
#
# The following fixtures are supported:
# - init
# - fini
# - disabled
# - timeout
set(data_expr "(${s}*,${s}*\\.${w}+${s}*=[^,\\)]+)*")
set(suites_wo_init_n_clean)
set(suites_w_init)
set(suites_w_clean)
file(READ "${SOURCE_FILE}" content)
# CU_Init and CU_Clean
#
# Extract all suite initializers and deinitializers so that the list of
# suites can be probably populated when tests and theories are parsed. Suites
# are only registered if it contains at least one test or theory.
set(suite_expr "CU_(Init|Clean)${s}*\\(${ident_expr}\\)")
string(REGEX MATCHALL "${suite_expr}" matches "${content}")
foreach(match ${matches})
string(REGEX REPLACE "${suite_expr}" "\\2" suite "${match}")
if("${match}" MATCHES "CU_Init")
list(APPEND suites_w_init ${suite})
elseif("${match}" MATCHES "CU_Clean")
list(APPEND suites_w_deinit ${suite})
endif()
endforeach()
# CU_Test
set(test_expr "CU_Test${s}*\\(${ident_expr},${ident_expr}${data_expr}\\)")
string(REGEX MATCHALL "${test_expr}" matches "${content}")
foreach(match ${matches})
string(REGEX REPLACE "${test_expr}" "\\1" suite "${match}")
string(REGEX REPLACE "${test_expr}" "\\2" test "${match}")
# Remove leading and trailing whitespace
string(STRIP "${suite}" suite)
string(STRIP "${test}" test)
# Extract fixtures that must be handled by CMake (.disabled and .timeout).
parse_cunit_fixtures("${match}" disabled timeout)
list(APPEND suites_wo_init_n_clean "${suite}")
list(APPEND tests "${suite}:${test}:${disabled}:${timeout}")
endforeach()
# CU_Theory
#
# CU_Theory signatures must be recognized in order to generate structures to
# hold the CU_DataPoints declarations. The generated type is added to the
# compile definitions and inserted by the preprocessor when CU_TheoryDataPoints
# is expanded.
#
# NOTE: Since not all compilers support pushing function-style definitions
# from the command line (CMake will generate a warning too), a header
# file is generated instead. A define is pushed and expanded at
# compile time. It is included by CUnit/Theory.h.
get_cunit_header_file("${SOURCE_FILE}" header)
set(theory_expr "CU_Theory${s}*\\(${s}*\\((${param_expr}(,${param_expr})*)\\)${s}*,${ident_expr},${ident_expr}${data_expr}\\)")
string(REGEX MATCHALL "${theory_expr}" matches "${content}")
foreach(match ${matches})
if(NOT theories)
# Ensure generated header is truncated before anything is written.
file(WRITE "${header}" "")
endif()
string(REGEX REPLACE "${theory_expr}" "\\1" params "${match}")
string(REGEX REPLACE "${theory_expr}" "\\7" suite "${match}")
string(REGEX REPLACE "${theory_expr}" "\\8" test "${match}")
# Remove leading and trailing whitespace
string(STRIP "${params}" params)
string(STRIP "${suite}" suite)
string(STRIP "${test}" test)
# Convert parameters from a string to a list
string(REGEX REPLACE "${s}*,${s}*" ";" params "${params}")
# Extract fixtures that must be handled by CMake (.disabled and .timeout)
parse_cunit_fixtures("${match}" disabled timeout)
list(APPEND suites_wo_init_n_clean "${suite}")
list(APPEND theories "${suite}:${test}:${disabled}:${timeout}")
set(sep)
set(size "CU_TheoryDataPointsSize_${suite}_${test}(datapoints) (")
set(slice "CU_TheoryDataPointsSlice_${suite}_${test}(datapoints, index) (")
set(typedef "CU_TheoryDataPointsTypedef_${suite}_${test}() {")
foreach(param ${params})
string(
REGEX REPLACE "(${type_expr})${ident_expr}" "\\3" name "${param}")
string(
REGEX REPLACE "(${type_expr})${ident_expr}" "\\1" type "${param}")
string(STRIP "${name}" name)
string(STRIP "${type}" type)
set(slice "${slice}${sep} datapoints.${name}.p[index]")
if (NOT sep)
set(size "${size} datapoints.${name}.n")
set(sep ",")
endif()
set(typedef "${typedef} struct { size_t n; ${type} *p; } ${name};")
endforeach()
set(typedef "${typedef} }")
set(slice "${slice} )")
set(size "${size} )")
file(APPEND "${header}" "#define ${size}\n")
file(APPEND "${header}" "#define ${slice}\n")
file(APPEND "${header}" "#define ${typedef}\n")
endforeach()
# Propagate suites, tests and theories extracted from the source file.
if(suites_wo_init_n_clean)
list(REMOVE_DUPLICATES suites_wo_init_n_clean)
list(SORT suites_wo_init_n_clean)
foreach(suite ${suites_wo_init_n_clean})
set(init "FALSE")
set(clean "FALSE")
if(${suite} IN_LIST suites_w_init)
set(init "TRUE")
endif()
if(${suite} IN_LIST suites_w_deinit)
set(clean "TRUE")
endif()
list(APPEND suites "${suite}:${init}:${clean}")
endforeach()
endif()
if(theories)
set(${HEADER_FILE} "${header}" PARENT_SCOPE)
else()
unset(${HEADER_FILE} PARENT_SCOPE)
endif()
set(${SUITES} ${suites} PARENT_SCOPE)
set(${TESTS} ${tests};${theories} PARENT_SCOPE)
endfunction()
function(add_cunit_executable TARGET)
# Retrieve location of shared libary, which is need to extend the PATH
# environment variable on Microsoft Windows, so that the operating
# system can locate the .dll that it was linked against.
# On macOS, this mechanism is used to set the DYLD_LIBRARY_PATH.
get_target_property(CUNIT_LIBRARY_TYPE CUnit TYPE)
get_target_property(CUNIT_IMPORTED_LOCATION CUnit IMPORTED_LOCATION)
get_filename_component(CUNIT_LIBRARY_DIR "${CUNIT_IMPORTED_LOCATION}" PATH)
set(decls)
set(defns)
set(sources)
foreach(source ${ARGN})
if((EXISTS "${source}" OR EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${source}"))
unset(suites)
unset(tests)
process_cunit_source_file("${source}" header suites tests)
if(header)
set_property(
SOURCE "${source}"
PROPERTY COMPILE_DEFINITIONS CU_THEORY_INCLUDE_FILE=\"${header}\")
endif()
# Disable missing-field-initializers warnings as not having to specify
# every member, aka fixture, is intended behavior.
if(${CMAKE_C_COMPILER_ID} STREQUAL "Clang" OR
${CMAKE_C_COMPILER_ID} STREQUAL "AppleClang" OR
${CMAKE_C_COMPILER_ID} STREQUAL "GNU")
set_property(
SOURCE "${source}"
PROPERTY COMPILE_FLAGS -Wno-missing-field-initializers)
endif()
foreach(suite ${suites})
string(REPLACE ":" ";" suite ${suite})
list(GET suite 2 clean)
list(GET suite 1 init)
list(GET suite 0 suite)
set(init_func "NULL")
set(clean_func "NULL")
if(init)
set(decls "${decls}\nCU_InitDecl(${suite});")
set(init_func "CU_InitName(${suite})")
endif()
if(clean)
set(decls "${decls}\nCU_CleanDecl(${suite});")
set(clean_func "CU_CleanName(${suite})")
endif()
set(defns "${defns}\nADD_SUITE(${suite}, ${init_func}, ${clean_func});")
endforeach()
foreach(test ${tests})
string(REPLACE ":" ";" test ${test})
list(GET test 3 timeout)
list(GET test 2 disabled)
list(GET test 0 suite)
list(GET test 1 test)
set(enable "true")
if(disabled)
set(enable "false")
endif()
if(NOT timeout)
set(timeout 10)
endif()
set(decls "${decls}\nCU_TestDecl(${suite}, ${test});")
set(defns "${defns}\nADD_TEST(${suite}, ${test}, ${enable});")
set(ctest "CUnit_${suite}_${test}")
add_test(
NAME ${ctest}
COMMAND ${TARGET} -a -r "${suite}-${test}" -s ${suite} -t ${test})
set_property(TEST ${ctest} PROPERTY TIMEOUT ${timeout})
set_property(TEST ${ctest} PROPERTY DISABLED ${disabled})
if(APPLE)
set_property(
TEST ${ctest}
PROPERTY ENVIRONMENT
"DYLD_LIBRARY_PATH=${CUNIT_LIBRARY_DIR}:$ENV{DYLD_LIBRARY_PATH}")
elseif(WIN32 AND ${CUNIT_LIBRARY_TYPE} STREQUAL "SHARED_LIBRARY")
set_property(
TEST ${ctest}
PROPERTY ENVIRONMENT
"PATH=${CUNIT_LIBRARY_DIR};$ENV{PATH}")
endif()
endforeach()
list(APPEND sources "${source}")
endif()
endforeach()
configure_file(
"${CUNIT_DIR}/src/main.c.in" "${CMAKE_CURRENT_BINARY_DIR}/${TARGET}.c" @ONLY)
if("2.1.3" VERSION_LESS_EQUAL
"${CUNIT_VERSION_MAJOR}.${CUNIT_VERSION_MINOR}.${CUNIT_VERSION_PATCH}")
set_property(
SOURCE "${CMAKE_CURRENT_BINARY_DIR}/${TARGET}.c"
PROPERTY COMPILE_DEFINITIONS HAVE_ENABLE_JUNIT_XML)
endif()
add_executable(
${TARGET} "${CMAKE_CURRENT_BINARY_DIR}/${TARGET}.c" ${sources})
target_link_libraries(${TARGET} PRIVATE CUnit)
target_include_directories(${TARGET} PRIVATE "${CUNIT_DIR}/include")
endfunction()

View file

@ -0,0 +1,96 @@
#ifndef CUNIT_TEST_H
#define CUNIT_TEST_H
#include <stdbool.h>
#include <CUnit/CUnit.h>
#include <CUnit/CUError.h>
#if defined (__cplusplus)
extern "C" {
#endif
typedef void(*cu_test_init_func_t)(void);
typedef void(*cu_test_fini_func_t)(void);
typedef struct {
cu_test_init_func_t init;
cu_test_fini_func_t fini;
int disabled; /* Parsed by CMake, used at test registration in main. */
int timeout; /* Parsed by CMake, used at test registration in CMake. */
} cu_data_t;
#define CU_InitName(suite) \
CU_Init_ ## suite
#define CU_CleanName(suite) \
CU_Fini_ ## suite
#define CU_TestName(suite, test) \
CU_Test_ ## suite ## _ ## test
#define CU_TestProxyName(suite, test) \
CU_TestProxy_ ## suite ## _ ## test
#define CU_InitDecl(suite) \
extern int CU_InitName(suite)(void)
#define CU_Init(suite) \
CU_InitDecl(suite); \
int CU_InitName(suite)(void)
#define CU_CleanDecl(suite) \
extern int CU_CleanName(suite)(void)
#define CU_Clean(suite) \
CU_CleanDecl(suite); \
int CU_CleanName(suite)(void)
/* CU_Test generates a wrapper function that takes care of per-test
initialization and deinitialization, if provided in the CU_Test
signature. */
#define CU_Test(suite, test, ...) \
static void CU_TestName(suite, test)(void); \
void CU_TestProxyName(suite, test)(void); \
\
void CU_TestProxyName(suite, test)(void) { \
cu_data_t data = CU_Fixture(__VA_ARGS__); \
\
if (data.init != NULL) { \
data.init(); \
} \
\
CU_TestName(suite, test)(); \
\
if (data.fini != NULL) { \
data.fini(); \
} \
} \
\
static void CU_TestName(suite, test)(void)
#define CU_TestDecl(suite, test) \
extern void CU_TestProxyName(suite, test)(void)
/* Microsoft Visual Studio does not like empty struct initializers, i.e.
no fixtures are specified. To work around that issue CU_Fixture inserts a
NULL initializer as fall back. */
#define CU_Comma() ,
#define CU_Reduce(one, ...) one
#ifdef _WIN32
/* Microsoft Visual Studio does not expand __VA_ARGS__ correctly. */
#define CU_Fixture__(...) CU_Fixture____((__VA_ARGS__))
#define CU_Fixture____(tuple) CU_Fixture___ tuple
#else
#define CU_Fixture__(...) CU_Fixture___(__VA_ARGS__)
#endif /* _WIN32 */
#define CU_Fixture___(throw, away, value, ...) value
#define CU_Fixture(...) \
CU_Fixture_( CU_Comma CU_Reduce(__VA_ARGS__,) (), __VA_ARGS__ )
#define CU_Fixture_(throwaway, ...) \
CU_Fixture__(throwaway, ((cu_data_t){ 0 }), ((cu_data_t){ __VA_ARGS__ }))
#if defined (__cplusplus)
}
#endif
#endif /* CUNIT_TEST_H */

View file

@ -0,0 +1,73 @@
#ifndef CUNIT_THEORY_H
#define CUNIT_THEORY_H
/* Function-style macros cannot be defined on the command line. */
#ifdef CU_THEORY_INCLUDE_FILE
#include CU_THEORY_INCLUDE_FILE
#endif
#include "CUnit/Test.h"
#if defined (__cplusplus)
extern "C" {
#endif
#define CU_TheoryDataPointsName(suite, test) \
CU_TheoryDataPoints_ ## suite ## _ ## test
#define CU_TheoryDataPointsTypeName(suite, test) \
CU_TheoryDataPointsType_ ## suite ## _ ## test
#define CU_TheoryDataPointsSize(suite, test) \
CU_TheoryDataPointsSize_ ## suite ## _ ## test ( \
CU_TheoryDataPointsName(suite, test))
#define CU_TheoryDataPointsSlice(suite, test, index) \
CU_TheoryDataPointsSlice_ ## suite ## _ ## test ( \
CU_TheoryDataPointsName(suite, test), index)
#define CU_TheoryDataPointsTypedef(suite, test) \
CU_TheoryDataPointsTypedef_ ## suite ## _ ## test()
#define CU_TheoryDataPoints(suite, test) \
struct CU_TheoryDataPointsTypeName(suite, test) \
CU_TheoryDataPointsTypedef(suite, test) ; \
\
static struct CU_TheoryDataPointsTypeName(suite, test) \
CU_TheoryDataPointsName(suite, test)
#define CU_DataPoints(type, ...) { \
.p = (type[]) { __VA_ARGS__ }, \
.n = (sizeof((type[]) { __VA_ARGS__ }) / sizeof(type)) \
}
#define CU_Theory(signature, suite, test, ...) \
static void CU_TestName(suite, test) signature; \
void CU_TestProxyName(suite, test)(void); \
\
void CU_TestProxyName(suite, test)(void) { \
cu_data_t data = CU_Fixture(__VA_ARGS__); \
size_t i, n; \
\
if (data.init != NULL) { \
data.init(); \
} \
\
for (i = 0, n = CU_TheoryDataPointsSize(suite, test); i < n; i++) { \
CU_TestName(suite, test) CU_TheoryDataPointsSlice(suite, test, i) ; \
} \
\
if (data.fini != NULL) { \
data.fini(); \
} \
} \
\
static void CU_TestName(suite, test) signature
#if defined (__cplusplus)
}
#endif
#endif /* CUNIT_THEORY_H */

View file

@ -0,0 +1,239 @@
/*
* Copyright(c) 2006 to 2018 ADLINK Technology Limited and others
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
* v. 1.0 which is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
*
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define EX_USAGE (64)
#define EX_SOFTWARE (70)
#include <CUnit/Basic.h>
#include <CUnit/Automated.h>
#include "CUnit/Test.h"
static struct {
bool print_help;
bool automated;
bool junit;
const char *results;
CU_BasicRunMode mode;
CU_ErrorAction error_action;
const char *suite;
const char *test;
} opts = {
false,
false,
false,
NULL,
CU_BRM_NORMAL,
CUEA_IGNORE,
"*",
"*"
};
static int patmatch(const char *pat, const char *str)
{
while (*pat) {
if (*pat == '?') {
/* any character will do */
if (*str++ == 0) {
return 0;
}
pat++;
} else if (*pat == '*') {
/* collapse a sequence of wildcards, requiring as many
characters in str as there are ?s in the sequence */
while (*pat == '*' || *pat == '?') {
if (*pat == '?' && *str++ == 0) {
return 0;
}
pat++;
}
/* try matching on all positions where str matches pat */
while (*str) {
if (*str == *pat && patmatch(pat+1, str+1)) {
return 1;
}
str++;
}
return *pat == 0;
} else {
/* only an exact match */
if (*str++ != *pat++) {
return 0;
}
}
}
return *str == 0;
}
static void usage(const char *name)
{
fprintf(stderr, "Usage: %s OPTIONS\n", name);
fprintf(stderr, "Try '%s -h' for more information\n", name);
}
static void help(const char *name)
{
printf("Usage: %s [OPTIONS]\n", name);
printf("\n");
printf("Possible options:\n");
printf(" -a run in automated mode\n");
printf(" -f fail fast\n");
printf(" -h display this help and exit\n");
printf(" -j junit format results \n");
printf(" -r FILENAME results file for automated run\n");
printf(" -s PATTERN run only tests in suites matching pattern\n");
printf(" -t PATTERN run only test matching pattern\n");
printf("\n");
printf("Exit codes:\n");
printf(" %-2d Successful termination\n", EXIT_SUCCESS);
printf(" %-2d One or more failing test cases\n", EXIT_FAILURE);
printf(" %-2d Command line usage error\n", EX_USAGE);
printf(" %-2d Internal software error\n", EX_SOFTWARE);
}
static int parse_options(int argc, char *argv[])
{
int err = 0;
for (int i = 1; err == 0 && i < argc; i++) {
switch ((argv[i][0] == '-') ? argv[i][1] : 0) {
case 'a':
opts.automated = true;
break;
case 'f':
opts.error_action = CUEA_FAIL;
break;
case 'h':
opts.print_help = true;
break;
case 'j':
opts.junit = true;
break;
case 'r':
if((i+1) < argc){
opts.results = argv[++i];
break;
}
/* FALLS THROUGH */
case 's':
if ((i+1) < argc) {
opts.suite = argv[++i];
break;
}
/* FALLS THROUGH */
case 't':
if ((i+1) < argc) {
opts.test = argv[++i];
break;
}
/* FALLS THROUGH */
default:
err = 1;
break;
}
}
return err;
}
static void
add_suite(
const char *suite,
CU_InitializeFunc pInitFunc,
CU_CleanupFunc pCleanFunc)
{
CU_pSuite pSuite;
pSuite = CU_get_suite(suite);
if (pSuite == NULL) {
pSuite = CU_add_suite(suite, pInitFunc, pCleanFunc);
CU_set_suite_active(pSuite, patmatch(opts.suite, suite));
}
}
#define ADD_SUITE(suite, init, clean) \
add_suite(#suite, init, clean)
static void
add_test(
const char *suite,
const char *test,
CU_TestFunc pTestFunc,
bool enable)
{
CU_pSuite pSuite;
CU_pTest pTest;
pSuite = CU_get_suite(suite);
pTest = CU_add_test(pSuite, test, pTestFunc);
CU_set_test_active(pTest, enable && patmatch(opts.test, test));
}
#define ADD_TEST(suite, test, enable) \
add_test(#suite, #test, CU_TestProxyName(suite, test), enable)
/* CMake will expand the macro below to declare generated functions. */
@decls@
int main(int argc, char *argv[])
{
int ret = EXIT_SUCCESS;
if (parse_options(argc, argv) != 0) {
usage(argv[0]);
return EX_USAGE;
} else if (opts.print_help) {
help(argv[0]);
return ret;
} else if (CU_initialize_registry() != CUE_SUCCESS) {
fprintf(stderr, "CU_initialize_registry: %s\n", CU_get_error_msg());
return EX_SOFTWARE;
}
/* CMake will expand the macro below to register all suites and tests. */
@defns@
CU_set_error_action(opts.error_action);
if (opts.automated) {
if (opts.results != NULL) {
CU_set_output_filename(opts.results);
}
#if defined(HAVE_ENABLE_JUNIT_XML)
if (opts.junit) {
CU_automated_enable_junit_xml(CU_TRUE);
} else
#endif
{
CU_list_tests_to_file();
}
CU_automated_run_tests();
} else {
CU_basic_set_mode(opts.mode);
CU_basic_run_tests();
}
if (CU_get_error() != CUE_SUCCESS) {
ret = EX_SOFTWARE;
} else if (CU_get_number_of_failures() != 0) {
ret = EXIT_FAILURE;
}
CU_cleanup_registry();
return ret;
}

View file

@ -0,0 +1,90 @@
#
# Copyright(c) 2006 to 2018 ADLINK Technology Limited and others
#
# This program and the accompanying materials are made available under the
# terms of the Eclipse Public License v. 2.0 which is available at
# http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
# v. 1.0 which is available at
# http://www.eclipse.org/org/documents/edl-v10.php.
#
# SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
#
set(CUNIT_HEADER "CUnit/CUnit.h")
if(CONAN_INCLUDE_DIRS)
find_path(CUNIT_INCLUDE_DIR ${CUNIT_HEADER} HINTS ${CONAN_INCLUDE_DIRS})
else()
find_path(CUNIT_INCLUDE_DIR ${CUNIT_HEADER})
endif()
mark_as_advanced(CUNIT_INCLUDE_DIR)
if(CUNIT_INCLUDE_DIR AND EXISTS "${CUNIT_INCLUDE_DIR}/${CUNIT_HEADER}")
set(PATTERN "^#define CU_VERSION \"([0-9]+)\\.([0-9]+)\\-([0-9]+)\"$")
file(STRINGS "${CUNIT_INCLUDE_DIR}/${CUNIT_HEADER}" CUNIT_H REGEX "${PATTERN}")
string(REGEX REPLACE "${PATTERN}" "\\1" CUNIT_VERSION_MAJOR "${CUNIT_H}")
string(REGEX REPLACE "${PATTERN}" "\\2" CUNIT_VERSION_MINOR "${CUNIT_H}")
string(REGEX REPLACE "${PATTERN}" "\\3" CUNIT_VERSION_PATCH "${CUNIT_H}")
set(CUNIT_VERSION "${CUNIT_VERSION_MAJOR}.${CUNIT_VERSION_MINOR}-${CUNIT_VERSION_PATCH}")
endif()
if(CONAN_LIB_DIRS)
find_library(CUNIT_LIBRARY cunit HINTS ${CONAN_LIB_DIRS})
else()
find_library(CUNIT_LIBRARY cunit)
endif()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(
CUnit
REQUIRED_VARS
CUNIT_LIBRARY CUNIT_INCLUDE_DIR
VERSION_VAR
CUNIT_VERSION)
if(CUNIT_FOUND)
set(CUNIT_INCLUDE_DIRS ${CUNIT_INCLUDE_DIR})
set(CUNIT_LIBRARIES ${CUNIT_LIBRARY})
if(WIN32)
get_filename_component(CUNIT_LIBRARY_DIR "${CUNIT_LIBRARY}}" PATH)
get_filename_component(CUNIT_BASENAME "${CUNIT_LIBRARY}}" NAME_WE)
get_filename_component(CUNIT_PREFIX "${CUNIT_LIBRARY_DIR}" PATH)
find_program(
CUNIT_DLL
"${CMAKE_SHARED_LIBRARY_PREFIX}${CUNIT_BASENAME}${CMAKE_SHARED_LIBRARY_SUFFIX}"
HINTS
${CUNIT_PREFIX}
PATH_SUFFIXES
bin
NO_DEFAULT_PATH)
mark_as_advanced(CUNIT_DLL)
# IMPORTANT:
# Providing a .dll file as the value for IMPORTED_LOCATION can only be
# done for "SHARED" libraries, otherwise the location of the .dll will be
# passed to linker, causing it to fail.
if(CUNIT_DLL)
add_library(CUnit SHARED IMPORTED)
set_target_properties(
CUnit PROPERTIES IMPORTED_IMPLIB "${CUNIT_LIBRARY}")
set_target_properties(
CUnit PROPERTIES IMPORTED_LOCATION "${CUNIT_DLL}")
else()
add_library(CUnit STATIC IMPORTED)
set_target_properties(
CUnit PROPERTIES IMPORTED_LOCATION "${CUNIT_LIBRARY}")
endif()
else()
add_library(CUnit UNKNOWN IMPORTED)
set_target_properties(
CUnit PROPERTIES IMPORTED_LOCATION "${CUNIT_LIBRARY}")
endif()
set_target_properties(
CUnit PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${CUNIT_INCLUDE_DIR}")
endif()

View file

@ -0,0 +1,83 @@
#
# Copyright(c) 2006 to 2018 ADLINK Technology Limited and others
#
# This program and the accompanying materials are made available under the
# terms of the Eclipse Public License v. 2.0 which is available at
# http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
# v. 1.0 which is available at
# http://www.eclipse.org/org/documents/edl-v10.php.
#
# SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
#
if(DEFINED ENV{M2})
list(APPEND _mvn_hints "$ENV{M2}")
endif()
if(DEFINED ENV{M2_HOME})
list(APPEND _mvn_hints "$ENV{M2_HOME}/bin")
endif()
# Chocolatey installs packages under C:\ProgramData\chocolatey.
if(NOT "$ENV{ProgramData}" STREQUAL "")
if(IS_DIRECTORY "$ENV{ProgramData}/chocolatey/bin")
list(APPEND _mvn_paths "$ENV{ProgramData}/chocolatey/bin")
endif()
if(IS_DIRECTORY "$ENV{ProgramData}/chocolatey/bin")
list(APPEND _dirs "$ENV{ProgramData}/chocolatey/lib/maven")
endif()
endif()
# Maven documentation mentions intalling maven under C:\Program Files on
# Windows and under /opt on *NIX platforms.
if(WIN32)
foreach(_env "ProgramFiles" "ProgramFiles(x86)")
if(ENV{${_env}} AND IS_DIRECTORY "$ENV{${_env}}")
list(APPEND _dirs "$ENV{${_env}}")
endif()
endforeach()
else()
list(APPEND _dirs "/opt")
endif()
foreach(_dir ${_dirs})
file(GLOB _mvn_dirs "${_dir}/apache-maven-*")
foreach(_mvn_dir ${_mvn_dirs})
if((IS_DIRECTORY "${_mvn_dir}") AND (IS_DIRECTORY "${_mvn_dir}/bin"))
list(APPEND _mvn_paths "${_mvn_dir}/bin")
endif()
endforeach()
endforeach()
if(WIN32)
set(_mvn_names "mvn.cmd" "mvn.exe")
else()
set(_mvn_names "mvn")
endif()
find_program(Maven_EXECUTABLE
NAMES ${_mvn_names}
HINTS ${_mvn_hints}
PATHS ${_mvn_paths})
if(Maven_EXECUTABLE)
execute_process(COMMAND ${Maven_EXECUTABLE} -version
RESULT_VARIABLE res
OUTPUT_VARIABLE var
ERROR_VARIABLE var
OUTPUT_STRIP_TRAILING_WHITESPACE
ERROR_STRIP_TRAILING_WHITESPACE)
if(NOT res)
if(var MATCHES "Apache Maven ([0-9]+)\\.([0-9]+)\\.([0-9]+)")
set(Maven_VERSION "${CMAKE_MATCH_1}.${CMAKE_MATCH_2}.${CMAKE_MATCH_3}")
endif()
endif()
endif()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Maven
FOUND_VAR Maven_FOUND
VERSION_VAR Maven_VERSION
REQUIRED_VARS Maven_EXECUTABLE Maven_VERSION)
mark_as_advanced(Maven_FOUND Maven_EXECUTABLE Maven_VERSION)

View file

@ -0,0 +1,34 @@
#
# Copyright(c) 2006 to 2018 ADLINK Technology Limited and others
#
# This program and the accompanying materials are made available under the
# terms of the Eclipse Public License v. 2.0 which is available at
# http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
# v. 1.0 which is available at
# http://www.eclipse.org/org/documents/edl-v10.php.
#
# SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
#
if(TARGET CONAN_PKG::OpenSSL)
add_library(OpenSSL::SSL INTERFACE IMPORTED)
target_link_libraries(OpenSSL::SSL INTERFACE CONAN_PKG::OpenSSL)
set(OPENSSL_FOUND TRUE)
else()
# Loop over a list of possible module paths (without the current directory).
get_filename_component(DIR "${CMAKE_CURRENT_LIST_DIR}" ABSOLUTE)
foreach(MODULE_DIR ${CMAKE_MODULE_PATH} ${CMAKE_ROOT}/Modules)
get_filename_component(MODULE_DIR "${MODULE_DIR}" ABSOLUTE)
if(NOT MODULE_DIR STREQUAL DIR)
if(EXISTS "${MODULE_DIR}/FindOpenSSL.cmake")
set(FIND_PACKAGE_FILE "${MODULE_DIR}/FindOpenSSL.cmake")
break()
endif()
endif()
endforeach()
if(FIND_PACKAGE_FILE)
include("${FIND_PACKAGE_FILE}")
endif()
endif()

View file

@ -0,0 +1,324 @@
#
# Copyright(c) 2019 Jeroen Koekkoek
#
# This program and the accompanying materials are made available under the
# terms of the Eclipse Public License v. 2.0 which is available at
# http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
# v. 1.0 which is available at
# http://www.eclipse.org/org/documents/edl-v10.php.
#
# SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
#
include(FindPackageHandleStandardArgs)
macro(_Sphinx_find_executable _exe)
string(TOUPPER "${_exe}" _uc)
# sphinx-(build|quickstart)-3 x.x.x
# FIXME: This works on Fedora (and probably most other UNIX like targets).
# Windows targets and PIP installs might need some work.
find_program(
SPHINX_${_uc}_EXECUTABLE
NAMES "sphinx-${_exe}-3" "sphinx-${_exe}" "sphinx-${_exe}.exe")
if(SPHINX_${_uc}_EXECUTABLE)
execute_process(
COMMAND "${SPHINX_${_uc}_EXECUTABLE}" --version
RESULT_VARIABLE _result
OUTPUT_VARIABLE _output
OUTPUT_STRIP_TRAILING_WHITESPACE)
if(_result EQUAL 0 AND _output MATCHES " ([0-9]+\\.[0-9]+\\.[0-9]+)$")
set(SPHINX_${_uc}_VERSION "${CMAKE_MATCH_1}")
endif()
add_executable(Sphinx::${_exe} IMPORTED GLOBAL)
set_target_properties(Sphinx::${_exe} PROPERTIES
IMPORTED_LOCATION "${SPHINX_${_uc}_EXECUTABLE}")
set(Sphinx_${_exe}_FOUND TRUE)
else()
set(Sphinx_${_exe}_FOUND FALSE)
endif()
unset(_uc)
endmacro()
macro(_Sphinx_find_extension _ext)
if(_SPHINX_PYTHON_EXECUTABLE)
execute_process(
COMMAND ${_SPHINX_PYTHON_EXECUTABLE} -c "import ${_ext}"
RESULT_VARIABLE _result)
if(_result EQUAL 0)
set(Sphinx_${_ext}_FOUND TRUE)
else()
set(Sphinx_${_ext}_FOUND FALSE)
endif()
elseif(CMAKE_HOST_WIN32 AND SPHINX_BUILD_EXECUTABLE)
# script-build on Windows located under (when PIP is used):
# C:/Program Files/PythonXX/Scripts
# C:/Users/username/AppData/Roaming/Python/PythonXX/Sripts
#
# Python modules are installed under:
# C:/Program Files/PythonXX/Lib
# C:/Users/username/AppData/Roaming/Python/PythonXX/site-packages
#
# To verify a given module is installed, use the Python base directory
# and test if either Lib/module.py or site-packages/module.py exists.
get_filename_component(_dirname "${SPHINX_BUILD_EXECUTABLE}" DIRECTORY)
get_filename_component(_dirname "${_dirname}" DIRECTORY)
if(IS_DIRECTORY "${_dirname}/Lib/${_ext}" OR
IS_DIRECTORY "${_dirname}/site-packages/${_ext}")
set(Sphinx_${_ext}_FOUND TRUE)
else()
set(Sphinx_${_ext}_FOUND FALSE)
endif()
endif()
endmacro()
#
# Find sphinx-build and sphinx-quickstart.
#
_Sphinx_find_executable(build)
_Sphinx_find_executable(quickstart)
#
# Verify both executables are part of the Sphinx distribution.
#
if(SPHINX_BUILD_EXECUTABLE AND SPHINX_QUICKSTART_EXECUTABLE)
if(NOT SPHINX_BUILD_VERSION STREQUAL SPHINX_QUICKSTART_VERSION)
message(FATAL_ERROR "Versions for sphinx-build (${SPHINX_BUILD_VERSION})"
"and sphinx-quickstart (${SPHINX_QUICKSTART_VERSION})"
"do not match")
endif()
endif()
#
# To verify the required Sphinx extensions are available, the right Python
# installation must be queried (2 vs 3). Of course, this only makes sense on
# UNIX-like systems.
#
if(NOT CMAKE_HOST_WIN32 AND SPHINX_BUILD_EXECUTABLE)
file(READ "${SPHINX_BUILD_EXECUTABLE}" _contents)
if(_contents MATCHES "^#!([^\n]+)")
string(STRIP "${CMAKE_MATCH_1}" _shebang)
if(EXISTS "${_shebang}")
set(_SPHINX_PYTHON_EXECUTABLE "${_shebang}")
endif()
endif()
endif()
foreach(_comp IN LISTS Sphinx_FIND_COMPONENTS)
if(_comp STREQUAL "build")
# Do nothing, sphinx-build is always required.
elseif(_comp STREQUAL "quickstart")
# Do nothing, sphinx-quickstart is optional, but looked up by default.
elseif(_comp STREQUAL "breathe")
_Sphinx_find_extension(${_comp})
else()
message(WARNING "${_comp} is not a valid or supported Sphinx extension")
set(Sphinx_${_comp}_FOUND FALSE)
continue()
endif()
endforeach()
find_package_handle_standard_args(
Sphinx
VERSION_VAR SPHINX_VERSION
REQUIRED_VARS SPHINX_BUILD_EXECUTABLE SPHINX_BUILD_VERSION
HANDLE_COMPONENTS)
# Generate a conf.py template file using sphinx-quickstart.
#
# sphinx-quickstart allows for quiet operation and a lot of settings can be
# specified as command line arguments, therefore its not required to parse the
# generated conf.py.
function(_Sphinx_generate_confpy _target _cachedir)
if(NOT TARGET Sphinx::quickstart)
message(FATAL_ERROR "sphinx-quickstart is not available, needed by"
"sphinx_add_docs for target ${_target}")
endif()
if(NOT DEFINED SPHINX_PROJECT)
set(SPHINX_PROJECT ${PROJECT_NAME})
endif()
if(NOT DEFINED SPHINX_AUTHOR)
set(SPHINX_AUTHOR "${SPHINX_PROJECT} committers")
endif()
if(NOT DEFINED SPHINX_COPYRIGHT)
string(TIMESTAMP "%Y, ${SPHINX_AUTHOR}" SPHINX_COPYRIGHT)
endif()
if(NOT DEFINED SPHINX_VERSION)
set(SPHINX_VERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}")
endif()
if(NOT DEFINED SPHINX_RELEASE)
set(SPHINX_RELEASE "${PROJECT_VERSION}")
endif()
if(NOT DEFINED SPHINX_LANGUAGE)
set(SPHINX_LANGUAGE "en")
endif()
set(_known_exts autodoc doctest intersphinx todo coverage imgmath mathjax
ifconfig viewcode githubpages)
if(DEFINED SPHINX_EXTENSIONS)
foreach(_ext ${SPHINX_EXTENSIONS})
set(_is_known_ext FALSE)
foreach(_known_ext ${_known_exsts})
if(_ext STREQUAL _known_ext)
set(_opts "${opts} --ext-${_ext}")
set(_is_known_ext TRUE)
break()
endif()
endforeach()
if(NOT _is_known_ext)
if(_exts)
set(_exts "${_exts},${_ext}")
else()
set(_exts "${_ext}")
endif()
endif()
endforeach()
endif()
if(_exts)
set(_exts "--extensions=${_exts}")
endif()
set(_templatedir "${CMAKE_CURRENT_BINARY_DIR}/${_target}.template")
file(MAKE_DIRECTORY "${_templatedir}")
execute_process(
COMMAND "${SPHINX_QUICKSTART_EXECUTABLE}"
-q --no-makefile --no-batchfile
-p "${SPHINX_PROJECT}"
-a "${SPHINX_AUTHOR}"
-v "${SPHINX_VERSION}"
-r "${SPHINX_RELEASE}"
-l "${SPHINX_LANGUAGE}"
${_opts} ${_exts} "${_templatedir}"
RESULT_VARIABLE _result
OUTPUT_QUIET)
if(_result EQUAL 0 AND EXISTS "${_templatedir}/conf.py")
file(COPY "${_templatedir}/conf.py" DESTINATION "${_cachedir}")
endif()
file(REMOVE_RECURSE "${_templatedir}")
if(NOT _result EQUAL 0 OR NOT EXISTS "${_cachedir}/conf.py")
message(FATAL_ERROR "Sphinx configuration file not generated for "
"target ${_target}")
endif()
endfunction()
function(sphinx_add_docs _target)
set(_opts)
set(_single_opts BUILDER OUTPUT_DIRECTORY SOURCE_DIRECTORY)
set(_multi_opts BREATHE_PROJECTS)
cmake_parse_arguments(_args "${_opts}" "${_single_opts}" "${_multi_opts}" ${ARGN})
unset(SPHINX_BREATHE_PROJECTS)
if(NOT _args_BUILDER)
message(FATAL_ERROR "Sphinx builder not specified for target ${_target}")
elseif(NOT _args_SOURCE_DIRECTORY)
message(FATAL_ERROR "Sphinx source directory not specified for target ${_target}")
else()
if(NOT IS_ABSOLUTE "${_args_SOURCE_DIRECTORY}")
get_filename_component(_sourcedir "${_args_SOURCE_DIRECTORY}" ABSOLUTE)
else()
set(_sourcedir "${_args_SOURCE_DIRECTORY}")
endif()
if(NOT IS_DIRECTORY "${_sourcedir}")
message(FATAL_ERROR "Sphinx source directory '${_sourcedir}' for"
"target ${_target} does not exist")
endif()
endif()
set(_builder "${_args_BUILDER}")
if(_args_OUTPUT_DIRECTORY)
set(_outputdir "${_args_OUTPUT_DIRECTORY}")
else()
set(_outputdir "${CMAKE_CURRENT_BINARY_DIR}/${_target}")
endif()
if(_args_BREATHE_PROJECTS)
if(NOT Sphinx_breathe_FOUND)
message(FATAL_ERROR "Sphinx extension 'breathe' is not available. Needed"
"by sphinx_add_docs for target ${_target}")
endif()
list(APPEND SPHINX_EXTENSIONS breathe)
foreach(_doxygen_target ${_args_BREATHE_PROJECTS})
if(TARGET ${_doxygen_target})
list(APPEND _depends ${_doxygen_target})
# Doxygen targets are supported. Verify that a Doxyfile exists.
get_target_property(_dir ${_doxygen_target} BINARY_DIR)
set(_doxyfile "${_dir}/Doxyfile.${_doxygen_target}")
if(NOT EXISTS "${_doxyfile}")
message(FATAL_ERROR "Target ${_doxygen_target} is not a Doxygen"
"target, needed by sphinx_add_docs for target"
"${_target}")
endif()
# Read the Doxyfile, verify XML generation is enabled and retrieve the
# output directory.
file(READ "${_doxyfile}" _contents)
if(NOT _contents MATCHES "GENERATE_XML *= *YES")
message(FATAL_ERROR "Doxygen target ${_doxygen_target} does not"
"generate XML, needed by sphinx_add_docs for"
"target ${_target}")
elseif(_contents MATCHES "OUTPUT_DIRECTORY *= *([^ ][^\n]*)")
string(STRIP "${CMAKE_MATCH_1}" _dir)
set(_name "${_doxygen_target}")
set(_dir "${_dir}/xml")
else()
message(FATAL_ERROR "Cannot parse Doxyfile generated by Doxygen"
"target ${_doxygen_target}, needed by"
"sphinx_add_docs for target ${_target}")
endif()
elseif(_doxygen_target MATCHES "([^: ]+) *: *(.*)")
set(_name "${CMAKE_MATCH_1}")
string(STRIP "${CMAKE_MATCH_2}" _dir)
endif()
if(_name AND _dir)
if(_breathe_projects)
set(_breathe_projects "${_breathe_projects}, \"${_name}\": \"${_dir}\"")
else()
set(_breathe_projects "\"${_name}\": \"${_dir}\"")
endif()
if(NOT _breathe_default_project)
set(_breathe_default_project "${_name}")
endif()
endif()
endforeach()
endif()
set(_cachedir "${CMAKE_CURRENT_BINARY_DIR}/${_target}.cache")
file(MAKE_DIRECTORY "${_cachedir}")
file(MAKE_DIRECTORY "${_cachedir}/_static")
_Sphinx_generate_confpy(${_target} "${_cachedir}")
if(_breathe_projects)
file(APPEND "${_cachedir}/conf.py"
"\nbreathe_projects = { ${_breathe_projects} }"
"\nbreathe_default_project = '${_breathe_default_project}'")
endif()
add_custom_target(
${_target}
COMMAND ${SPHINX_BUILD_EXECUTABLE}
-b ${_builder}
-d "${CMAKE_CURRENT_BINARY_DIR}/${_target}.cache/_doctrees"
-c "${CMAKE_CURRENT_BINARY_DIR}/${_target}.cache"
"${_sourcedir}"
"${_outputdir}"
DEPENDS ${_depends})
endfunction()

View file

@ -0,0 +1,51 @@
# Copyright(c) 2006 to 2018 ADLINK Technology Limited and others
#
# This program and the accompanying materials are made available under the
# terms of the Eclipse Public License v. 2.0 which is available at
# http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
# v. 1.0 which is available at
# http://www.eclipse.org/org/documents/edl-v10.php.
#
# SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
function(GENERATE_DUMMY_EXPORT_HEADER _target)
set(_opts)
set(_single_opts BASE_NAME EXPORT_FILE_NAME)
set(_multi_opts)
cmake_parse_arguments(_args "${_opts}" "${_single_opts}" "${_multi_opts}" ${ARGN})
if(NOT _target)
message(FATAL_ERROR "Target not specified")
elseif(NOT TARGET ${_target})
message(FATAL_ERROR "Target ${_target} does not exist")
endif()
string(TOUPPER _target_uc "${_target}")
string(TOLOWER _target_lc "${_target}")
if(_args_EXPORT_FILE_NAME)
set(_path "${_args_EXPORT_FILE_NAME}")
else()
set(_path "${CMAKE_CURRENT_BINARY_DIR}/${_target_lc}_export.h")
endif()
if(_args_BASE_NAME)
string(TOUPPER "${_args_BASE_NAME}" _base_name)
else()
set(_base_name "${_target_uc}")
endif()
get_filename_component(_dir "${_path}" DIRECTORY)
get_filename_component(_file "${_path}" NAME)
if(NOT IS_DIRECTORY "${_dir}")
file(MAKE_DIRECTORY "${_dir}")
endif()
set(_content
"/* Dummy export header generated by CMake. */
#define ${_base_name}_EXPORT\n")
file(WRITE "${_path}" "${_content}")
endfunction()

38
cmake/Modules/Glob.cmake Normal file
View file

@ -0,0 +1,38 @@
#
# Copyright(c) 2006 to 2018 ADLINK Technology Limited and others
#
# This program and the accompanying materials are made available under the
# terms of the Eclipse Public License v. 2.0 which is available at
# http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
# v. 1.0 which is available at
# http://www.eclipse.org/org/documents/edl-v10.php.
#
# SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
#
function(glob variable extension)
set(dirname "${CMAKE_CURRENT_SOURCE_DIR}")
foreach(filename ${ARGN})
unset(filenames)
if((NOT IS_ABSOLUTE "${filename}") AND
(EXISTS "${dirname}/${filename}"))
set(filename "${dirname}/${filename}")
endif()
if(IS_DIRECTORY "${filename}")
file(GLOB_RECURSE filenames "${filename}/*.${extension}")
elseif(EXISTS "${filename}")
if("${filename}" MATCHES "\.${extension}$")
set(filenames "${filename}")
endif()
else()
message(FATAL_ERROR "File ${filename} does not exist")
endif()
list(APPEND files ${filenames})
endforeach()
set(${variable} "${files}" PARENT_SCOPE)
endfunction()

View file

@ -0,0 +1,147 @@
#
# Copyright(c) 2006 to 2018 ADLINK Technology Limited and others
#
# This program and the accompanying materials are made available under the
# terms of the Eclipse Public License v. 2.0 which is available at
# http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
# v. 1.0 which is available at
# http://www.eclipse.org/org/documents/edl-v10.php.
#
# SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
#
if(PACKAGING_INCLUDED)
return()
endif()
set(PACKAGING_INCLUDED true)
include(CMakePackageConfigHelpers)
include(GNUInstallDirs)
set(PACKAGING_MODULE_DIR "${PROJECT_SOURCE_DIR}/cmake/Modules/Packaging")
set(CMAKE_INSTALL_CMAKEDIR "${CMAKE_INSTALL_DATADIR}/${CMAKE_PROJECT_NAME}")
# Generates <Package>Config.cmake.
configure_package_config_file(
"${PACKAGING_MODULE_DIR}/PackageConfig.cmake.in"
"${CMAKE_PROJECT_NAME}Config.cmake"
INSTALL_DESTINATION "${CMAKE_INSTALL_CMAKEDIR}")
# Generates <Package>Version.cmake.
write_basic_package_version_file(
"${CMAKE_PROJECT_NAME}Version.cmake"
VERSION ${PROJECT_VERSION}
COMPATIBILITY SameMajorVersion)
install(
FILES "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_PROJECT_NAME}Config.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_PROJECT_NAME}Version.cmake"
DESTINATION "${CMAKE_INSTALL_CMAKEDIR}" COMPONENT dev)
if((NOT DEFINED BUILD_SHARED_LIBS) OR BUILD_SHARED_LIBS)
# Generates <Package>Targets.cmake file included by <Package>Config.cmake.
# The files are placed in CMakeFiles/Export in the build tree.
install(
EXPORT "${CMAKE_PROJECT_NAME}"
FILE "${CMAKE_PROJECT_NAME}Targets.cmake"
NAMESPACE "${CMAKE_PROJECT_NAME}::"
DESTINATION "${CMAKE_INSTALL_CMAKEDIR}" COMPONENT dev)
endif()
set(CPACK_PACKAGE_VERSION_MAJOR ${PROJECT_VERSION_MAJOR})
set(CPACK_PACKAGE_VERSION_MINOR ${PROJECT_VERSION_MINOR})
set(CPACK_PACKAGE_VERSION_PATCH ${PROJECT_VERSION_PATCH})
set(CPACK_PACKAGE_VERSION_TWEAK ${PROJECT_VERSION_TWEAK})
set(CPACK_PACKAGE_VERSION ${PROJECT_VERSION})
set(CPACK_PACKAGE_NAME ${CMAKE_PROJECT_NAME})
set(CPACK_PACKAGE_VENDOR "Eclipse Cyclone DDS project")
set(CPACK_PACKAGE_CONTACT "https://github.com/eclipse-cyclonedds/cyclonedds")
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Implementation of the OMG DDS standard")
# WiX requires a .txt file extension for CPACK_RESOURCE_FILE_LICENSE
file(COPY "${PROJECT_SOURCE_DIR}/LICENSE" DESTINATION "${CMAKE_BINARY_DIR}")
file(RENAME "${CMAKE_BINARY_DIR}/LICENSE" "${CMAKE_BINARY_DIR}/license.txt")
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_BINARY_DIR}/license.txt")
# Packages could be generated on alien systems. e.g. Debian packages could be
# created on Red Hat Enterprise Linux, but since packages also need to be
# verified on the target platform, please refrain from doing so. Another
# reason for building installer packages on the target platform is to ensure
# the binaries are linked to the libc version shipped with that platform. To
# support "generic" Linux distributions, eventually compressed tarballs will
# be shipped.
#
# NOTE: Settings for different platforms are in separate control branches.
# Although that does not make sense from a technical point-of-view, it
# does help to clearify which settings are required for a platform.
set(CPACK_COMPONENTS_ALL dev lib)
set(CPACK_COMPONENT_LIB_DISPLAY_NAME "${CMAKE_PROJECT_NAME_FULL} library")
set(CPACK_COMPONENT_LIB_DESCRIPTION "Library used to run programs with ${CMAKE_PROJECT_NAME_FULL}")
set(CPACK_COMPONENT_DEV_DISPLAY_NAME "${CMAKE_PROJECT_NAME_FULL} development")
set(CPACK_COMPONENT_DEV_DESCRIPTION "Development files for use with ${CMAKE_PROJECT_NAME_FULL}")
if(WIN32 AND NOT UNIX)
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
set(__arch "win64")
else()
set(__arch "win32")
endif()
mark_as_advanced(__arch)
set(CPACK_GENERATOR "WIX;ZIP;${CPACK_GENERATOR}" CACHE STRING "List of package generators")
set(CPACK_PACKAGE_FILE_NAME "${CMAKE_PROJECT_NAME}-${CPACK_PACKAGE_VERSION}-${__arch}")
set(CPACK_PACKAGE_INSTALL_DIRECTORY "${CMAKE_PROJECT_NAME_FULL}")
include(InstallRequiredSystemLibraries)
elseif(CMAKE_SYSTEM_NAME MATCHES "Linux")
# CMake prior to v3.6 messes up the name of the packages. >= v3.6 understands CPACK_RPM/DEBIAN_<component>_FILE_NAME
cmake_minimum_required(VERSION 3.6)
set(CPACK_COMPONENTS_GROUPING "IGNORE")
# FIXME: Requiring lsb_release to be installed may be a viable option.
if(EXISTS "/etc/redhat-release")
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
set(__arch "x86_64")
else()
set(__arch "i686")
endif()
set(CPACK_GENERATOR "RPM;TGZ;${CPACK_GENERATOR}" CACHE STRING "List of package generators")
set(CPACK_RPM_COMPONENT_INSTALL ON)
# FIXME: The package file name must be updated to include the distribution.
# See Fedora and Red Hat packaging guidelines for details.
set(CPACK_RPM_LIB_PACKAGE_NAME "${CMAKE_PROJECT_NAME_DASHED}")
set(CPACK_RPM_LIB_FILE_NAME "${CPACK_RPM_LIB_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-${__arch}.rpm")
set(CPACK_RPM_DEV_PACKAGE_NAME "${CPACK_RPM_LIB_PACKAGE_NAME}-devel")
set(CPACK_RPM_DEV_FILE_NAME "${CPACK_RPM_DEV_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-${__arch}.rpm")
set(CPACK_RPM_DEV_PACKAGE_REQUIRES "${CPACK_RPM_LIB_PACKAGE_NAME} = ${CPACK_PACKAGE_VERSION}")
elseif(EXISTS "/etc/debian_version")
set(CPACK_DEB_COMPONENT_INSTALL ON)
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
set(__arch "amd64")
else()
set(__arch "i386")
endif()
set(CPACK_GENERATOR "DEB;TGZ;${CPACK_GENERATOR}" CACHE STRING "List of package generators")
string(TOLOWER "${CMAKE_PROJECT_NAME_DASHED}" CPACK_DEBIAN_LIB_PACKAGE_NAME)
set(CPACK_DEBIAN_LIB_FILE_NAME "${CPACK_DEBIAN_LIB_PACKAGE_NAME}_${CPACK_PACKAGE_VERSION}_${__arch}.deb")
set(CPACK_DEBIAN_DEV_PACKAGE_DEPENDS "${CPACK_DEBIAN_LIB_PACKAGE_NAME} (= ${CPACK_PACKAGE_VERSION}), libc6 (>= 2.23)")
set(CPACK_DEBIAN_DEV_PACKAGE_NAME "${CPACK_DEBIAN_LIB_PACKAGE_NAME}-dev")
set(CPACK_DEBIAN_DEV_FILE_NAME "${CPACK_DEBIAN_DEV_PACKAGE_NAME}_${CPACK_PACKAGE_VERSION}_${__arch}.deb")
else()
# Generic tgz package
set(CPACK_GENERATOR "TGZ;${CPACK_GENERATOR}" CACHE STRING "List of package generators")
endif()
endif()
# This must always be last!
include(CPack)

View file

@ -0,0 +1,16 @@
#
# Copyright(c) 2006 to 2018 ADLINK Technology Limited and others
#
# This program and the accompanying materials are made available under the
# terms of the Eclipse Public License v. 2.0 which is available at
# http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
# v. 1.0 which is available at
# http://www.eclipse.org/org/documents/edl-v10.php.
#
# SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
#
@PACKAGE_INIT@
include("${CMAKE_CURRENT_LIST_DIR}/@CMAKE_PROJECT_NAME@Targets.cmake")
include("${CMAKE_CURRENT_LIST_DIR}/idlc/IdlcGenerate.cmake")