From 19b4fd074412f1fe74f4f496c72b84a7b04ff408 Mon Sep 17 00:00:00 2001 From: Zoltan Gyarmati Date: Tue, 12 Feb 2019 19:02:44 +0100 Subject: [PATCH 1/4] rename test binary to test-toml to avoid cmake warning Policy CMP0037 --- .gitignore | 2 +- CMakeLists.txt | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index eb8292f..605f9fc 100644 --- a/.gitignore +++ b/.gitignore @@ -3,7 +3,7 @@ libtoml.dylib libtoml.so main main.o -test +test-toml test.o toml.o toml_parse.c diff --git a/CMakeLists.txt b/CMakeLists.txt index 76ff67a..f25042c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -32,5 +32,5 @@ TARGET_LINK_LIBRARIES(toml ${PC_LIBICU_LIBRARIES}) ADD_EXECUTABLE(main main.c) TARGET_LINK_LIBRARIES(main toml ${PC_LIBICU_LIBRARIES}) -ADD_EXECUTABLE(test test.c) -TARGET_LINK_LIBRARIES(test toml ${PC_LIBICU_LIBRARIES} ${PC_CUNIT_LIBRARIES}) +ADD_EXECUTABLE(test-toml test.c) +TARGET_LINK_LIBRARIES(test-toml toml ${PC_LIBICU_LIBRARIES} ${PC_CUNIT_LIBRARIES}) From 17f14d5ac9e51c3ea9f2b647d0ea65f5a4776f43 Mon Sep 17 00:00:00 2001 From: Zoltan Gyarmati Date: Tue, 12 Feb 2019 19:15:45 +0100 Subject: [PATCH 2/4] cmake: fix out-of-tree compilation by prefixing the RAGEL source file --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f25042c..199b80b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,7 +6,7 @@ FIND_PACKAGE(PkgConfig) PKG_CHECK_MODULES(PC_LIBICU icu-uc) PKG_CHECK_MODULES(PC_CUNIT cunit) -SET(RAGEL_SRCS toml_parse.rl) +SET(RAGEL_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/toml_parse.rl) SET(CMAKE_INCLUDE_CURRENT_DIR TRUE) INCLUDE_DIRECTORIES(${PC_LIBICU_INCLUDE_DIRS} ${PC_CUNIT_INCLUDE_DIRS}) From d1d149235c584d67fd050ce3aca3ed535d9d9a31 Mon Sep 17 00:00:00 2001 From: Zoltan Gyarmati Date: Tue, 12 Feb 2019 19:47:55 +0100 Subject: [PATCH 3/4] cmake: set mandatory dependencies to REQUIRED, so cmake will explicitly fail if they were not found CUnit is also checked, and the tests are built only if it was found --- CMakeLists.txt | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 199b80b..c0cfb7f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,8 +2,12 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.6) PROJECT(libtoml) FIND_PROGRAM(RAGEL ragel) +if(NOT RAGEL) + message(FATAL_ERROR "Ragel executable not found!") +endif() + FIND_PACKAGE(PkgConfig) -PKG_CHECK_MODULES(PC_LIBICU icu-uc) +PKG_CHECK_MODULES(PC_LIBICU REQUIRED icu-uc) PKG_CHECK_MODULES(PC_CUNIT cunit) SET(RAGEL_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/toml_parse.rl) @@ -32,5 +36,10 @@ TARGET_LINK_LIBRARIES(toml ${PC_LIBICU_LIBRARIES}) ADD_EXECUTABLE(main main.c) TARGET_LINK_LIBRARIES(main toml ${PC_LIBICU_LIBRARIES}) -ADD_EXECUTABLE(test-toml test.c) -TARGET_LINK_LIBRARIES(test-toml toml ${PC_LIBICU_LIBRARIES} ${PC_CUNIT_LIBRARIES}) + +if(NOT PC_CUNIT_FOUND) + message(WARNING "CUnit was not found, not building tests") +else() + ADD_EXECUTABLE(test-toml test.c) + TARGET_LINK_LIBRARIES(test-toml toml ${PC_LIBICU_LIBRARIES} ${PC_CUNIT_LIBRARIES}) +endif() From 3e984b0a5cebd82d1a316acb6cdf0f0e6f089247 Mon Sep 17 00:00:00 2001 From: Zoltan Gyarmati Date: Tue, 12 Feb 2019 19:51:34 +0100 Subject: [PATCH 4/4] delete duplicated build_assert.h file --- ccan/build_assert.h | 39 --------------------------------------- 1 file changed, 39 deletions(-) delete mode 100644 ccan/build_assert.h diff --git a/ccan/build_assert.h b/ccan/build_assert.h deleted file mode 100644 index c6ee362..0000000 --- a/ccan/build_assert.h +++ /dev/null @@ -1,39 +0,0 @@ -#ifndef CCAN_BUILD_ASSERT_H -#define CCAN_BUILD_ASSERT_H - -/** - * BUILD_ASSERT - assert a build-time dependency. - * @cond: the compile-time condition which must be true. - * - * Your compile will fail if the condition isn't true, or can't be evaluated - * by the compiler. This can only be used within a function. - * - * Example: - * #include - * ... - * static char *foo_to_char(struct foo *foo) - * { - * // This code needs string to be at start of foo. - * BUILD_ASSERT(offsetof(struct foo, string) == 0); - * return (char *)foo; - * } - */ -#define BUILD_ASSERT(cond) \ - do { (void) sizeof(char [1 - 2*!(cond)]); } while(0) - -/** - * EXPR_BUILD_ASSERT - assert a build-time dependency, as an expression. - * @cond: the compile-time condition which must be true. - * - * Your compile will fail if the condition isn't true, or can't be evaluated - * by the compiler. This can be used in an expression: its value is "0". - * - * Example: - * #define foo_to_char(foo) \ - * ((char *)(foo) \ - * + EXPR_BUILD_ASSERT(offsetof(struct foo, string) == 0)) - */ -#define EXPR_BUILD_ASSERT(cond) \ - (sizeof(char [1 - 2*!(cond)]) - 1) - -#endif /* CCAN_BUILD_ASSERT_H */