From 0bb1a6dfba10ec1eadacd0b7f721652fbe1f031a Mon Sep 17 00:00:00 2001 From: Aleksei Aleksandrovich Drozdovskii Date: Mon, 26 Nov 2018 13:41:23 +0300 Subject: [PATCH 1/6] Add support CMake build (#2) --- CMakeLists.txt | 81 ++++++++++++++++++++++++++++++++++++++++++++ tests/CMakeLists.txt | 24 +++++++++++++ 2 files changed, 105 insertions(+) create mode 100644 CMakeLists.txt create mode 100644 tests/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 00000000..53ad206d --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,81 @@ +cmake_minimum_required(VERSION 3.8) +project(gumbo) + +set(CMAKE_CXX_STANDARD 17) + +set(SRC + src/attribute.c + src/char_ref.c + src/error.c + src/parser.c + src/string_buffer.c + src/string_piece.c + src/tag.c + src/tokenizer.c + src/utf8.c + src/util.c + src/vector.c + ) + +set(HEADERS + src/attribute.h + src/char_ref.h + src/error.h + src/gumbo.h + src/insertion_mode.h + src/parser.h + src/string_buffer.h + src/string_piece.h + src/tag_enum.h + src/tag_gperf.h + src/tag_sizes.h + src/tag_strings.h + src/tokenizer.h + src/tokenizer_states.h + src/token_type.h + src/utf8.h + src/util.h + src/vector.h + ) + +add_library(gumbo STATIC + # headers + ${HEADERS} + # sources + ${SRC} + ) + +file(GLOB HEAD_FILES + src/gumbo.h + src/tag_enum.h + ) +if(MSVC) + list(APPEND HEAD_FILES visualc/include/strings.h) +endif() + +file(INSTALL ${HEAD_FILES} DESTINATION ${CMAKE_BINARY_DIR}/include/gumbo) + +target_include_directories(gumbo + PUBLIC + $ + $ + #For support include different way. (gumbo/gumbo.h or gumbo.h) + $ + $ + ) + +install(FILES + ${HEAD_FILES} DESTINATION + ${CMAKE_INSTALL_PREFIX}/include/gumbo + ) + +install( + TARGETS gumbo + EXPORT "${TARGETS_EXPORT_NAME}" + LIBRARY DESTINATION "lib" + ARCHIVE DESTINATION "lib" + RUNTIME DESTINATION "bin" + INCLUDES DESTINATION "${CMAKE_INSTALL_PREFIX}/include/gumbo" + ) + +add_subdirectory(tests) \ No newline at end of file diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt new file mode 100644 index 00000000..d518ffac --- /dev/null +++ b/tests/CMakeLists.txt @@ -0,0 +1,24 @@ +find_package(GTest REQUIRED) + +add_executable(gumbo_tests + attribute.cc + char_ref.cc + parser.cc + string_buffer.cc + string_piece.cc + test_utils.cc + tokenizer.cc + utf8.cc + vector.cc + ) + +target_include_directories(gumbo_tests + PRIVATE + "${PROJECT_SOURCE_DIR}/src" + ) + +target_link_libraries(gumbo_tests + PRIVATE + gumbo + GTest::GTest + GTest::Main) From 2e446bd6770f3fbc1fca15939b2e934fbfa3134e Mon Sep 17 00:00:00 2001 From: Aleksei Drozdovskii Date: Mon, 26 Nov 2018 15:52:07 +0300 Subject: [PATCH 2/6] Fix FindGtest --- tests/CMakeLists.txt | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index d518ffac..70c894b8 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -1,6 +1,8 @@ +set(GTEST_ROOT "${CMAKE_INSTALL_PREFIX}/") find_package(GTest REQUIRED) add_executable(gumbo_tests + test_utils.h attribute.cc char_ref.cc parser.cc @@ -19,6 +21,7 @@ target_include_directories(gumbo_tests target_link_libraries(gumbo_tests PRIVATE - gumbo GTest::GTest - GTest::Main) + GTest::Main + gumbo + ) From 90269cf1ff0daf040ae57fa6bb93c99df9ea566c Mon Sep 17 00:00:00 2001 From: Aleksei Aleksandrovich Drozdovskii Date: Fri, 18 Jan 2019 00:45:39 +0300 Subject: [PATCH 3/6] Disable building tests by default via option BUILD_GUMBO_TESTS --- CMakeLists.txt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 53ad206d..4b94a531 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -78,4 +78,7 @@ install( INCLUDES DESTINATION "${CMAKE_INSTALL_PREFIX}/include/gumbo" ) -add_subdirectory(tests) \ No newline at end of file +option(BUILD_GUMBO_TESTS "Builds gumbo tests" OFF) +if(BUILD_GUMBO_TESTS) + add_subdirectory(tests) +endif() From 913db98e08068e0fdc69bcc43284e97c5e3acfdd Mon Sep 17 00:00:00 2001 From: Aleksei Drozdoskii Date: Mon, 21 Jan 2019 14:25:31 +0300 Subject: [PATCH 4/6] Fix style CMakeLists.txt --- CMakeLists.txt | 140 ++++++++++++++++++++----------------------------- 1 file changed, 56 insertions(+), 84 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4b94a531..06444b8a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,84 +1,56 @@ -cmake_minimum_required(VERSION 3.8) -project(gumbo) - -set(CMAKE_CXX_STANDARD 17) - -set(SRC - src/attribute.c - src/char_ref.c - src/error.c - src/parser.c - src/string_buffer.c - src/string_piece.c - src/tag.c - src/tokenizer.c - src/utf8.c - src/util.c - src/vector.c - ) - -set(HEADERS - src/attribute.h - src/char_ref.h - src/error.h - src/gumbo.h - src/insertion_mode.h - src/parser.h - src/string_buffer.h - src/string_piece.h - src/tag_enum.h - src/tag_gperf.h - src/tag_sizes.h - src/tag_strings.h - src/tokenizer.h - src/tokenizer_states.h - src/token_type.h - src/utf8.h - src/util.h - src/vector.h - ) - -add_library(gumbo STATIC - # headers - ${HEADERS} - # sources - ${SRC} - ) - -file(GLOB HEAD_FILES - src/gumbo.h - src/tag_enum.h - ) -if(MSVC) - list(APPEND HEAD_FILES visualc/include/strings.h) -endif() - -file(INSTALL ${HEAD_FILES} DESTINATION ${CMAKE_BINARY_DIR}/include/gumbo) - -target_include_directories(gumbo - PUBLIC - $ - $ - #For support include different way. (gumbo/gumbo.h or gumbo.h) - $ - $ - ) - -install(FILES - ${HEAD_FILES} DESTINATION - ${CMAKE_INSTALL_PREFIX}/include/gumbo - ) - -install( - TARGETS gumbo - EXPORT "${TARGETS_EXPORT_NAME}" - LIBRARY DESTINATION "lib" - ARCHIVE DESTINATION "lib" - RUNTIME DESTINATION "bin" - INCLUDES DESTINATION "${CMAKE_INSTALL_PREFIX}/include/gumbo" - ) - -option(BUILD_GUMBO_TESTS "Builds gumbo tests" OFF) -if(BUILD_GUMBO_TESTS) - add_subdirectory(tests) -endif() +cmake_minimum_required(VERSION 3.11) +project(gumbo) + +set(CMAKE_CXX_STANDARD 17) + +file(GLOB HEADERS_FILES + src/*.h + ) + +file(GLOB EXPORT_HEADERS_FILES + src/gumbo.h + src/tag_enum.h + ) + +if(MSVC) + list(APPEND HEADERS_EXPORT_FILES visualc/include/strings.h) +endif() + +file(INSTALL ${EXPORT_HEADERS_FILES} DESTINATION ${CMAKE_BINARY_DIR}/include/gumbo) + +file(GLOB SOURCES_FILES + src/*.c + ) + +add_library(gumbo STATIC + ${HEADERS_FILES} + ${SOURCES_FILES} + ) + +target_include_directories(gumbo + PUBLIC + $ + $ + # For support include different way. (gq/Document.h or Document.h) + $ + $ + ) + +install(FILES + ${EXPORT_HEADERS_FILES} DESTINATION + ${CMAKE_INSTALL_PREFIX}/include/gumbo + ) + +install( + TARGETS gumbo + EXPORT "${TARGETS_EXPORT_NAME}" + LIBRARY DESTINATION "lib" + ARCHIVE DESTINATION "lib" + RUNTIME DESTINATION "bin" + INCLUDES DESTINATION "include/gumbo" + ) + +option(BUILD_GUMBO_TESTS "Builds gumbo tests" OFF) +if(BUILD_GUMBO_TESTS) + add_subdirectory(tests) +endif() From 8c5cd4578b6f2a80d11f51af9ebe17e44bf597a8 Mon Sep 17 00:00:00 2001 From: Aleksei Aleksandrovich Drozdovskii Date: Mon, 21 Jan 2019 15:03:42 +0300 Subject: [PATCH 5/6] Update CMakeLists.txt --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 06444b8a..23a9ce32 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -13,7 +13,7 @@ file(GLOB EXPORT_HEADERS_FILES ) if(MSVC) - list(APPEND HEADERS_EXPORT_FILES visualc/include/strings.h) + list(APPEND EXPORT_HEADERS_FILES visualc/include/strings.h) endif() file(INSTALL ${EXPORT_HEADERS_FILES} DESTINATION ${CMAKE_BINARY_DIR}/include/gumbo) @@ -31,7 +31,7 @@ target_include_directories(gumbo PUBLIC $ $ - # For support include different way. (gq/Document.h or Document.h) + # For support include different way. (gq/gumbo.h or gumbo.h) $ $ ) From 6022289a5731d3c2b46a71b3cba8777551f90691 Mon Sep 17 00:00:00 2001 From: Aleksei Drozdoskii Date: Mon, 21 Jan 2019 15:11:47 +0300 Subject: [PATCH 6/6] Update CMakeLists.txt --- CMakeLists.txt | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 23a9ce32..8171a960 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -31,14 +31,13 @@ target_include_directories(gumbo PUBLIC $ $ - # For support include different way. (gq/gumbo.h or gumbo.h) + # For support include different way. (gumbo/gumbo.h or gumbo.h) $ $ ) -install(FILES - ${EXPORT_HEADERS_FILES} DESTINATION - ${CMAKE_INSTALL_PREFIX}/include/gumbo +install(FILES ${EXPORT_HEADERS_FILES} + DESTINATION ${CMAKE_INSTALL_PREFIX}/include/gumbo ) install(