Skip to content
This repository has been archived by the owner on Feb 15, 2023. It is now read-only.

Add support CMake build #408

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 55 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
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 EXPORT_HEADERS_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
$<BUILD_INTERFACE:${CMAKE_BINARY_DIR}/include>
$<INSTALL_INTERFACE:include>
# For support include different way. (gumbo/gumbo.h or gumbo.h)
$<BUILD_INTERFACE:${CMAKE_BINARY_DIR}/include/gumbo>
$<INSTALL_INTERFACE:include/gumbo>
)

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()
27 changes: 27 additions & 0 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
set(GTEST_ROOT "${CMAKE_INSTALL_PREFIX}/")
find_package(GTest REQUIRED)

add_executable(gumbo_tests
test_utils.h
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
GTest::GTest
GTest::Main
gumbo
)