Skip to content

Commit 967c159

Browse files
committed
Added CMakeLists.txt, updated paths
1 parent 1ffdf4c commit 967c159

File tree

3 files changed

+316
-1
lines changed

3 files changed

+316
-1
lines changed

.gitignore

Lines changed: 190 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,190 @@
1+
## Ignore Visual Studio temporary files, build results, and
2+
## files generated by popular Visual Studio add-ons.
3+
4+
# User-specific files
5+
*.suo
6+
*.user
7+
*.sln.docstates
8+
9+
# Build results
10+
cmake-build-*/
11+
[Dd]ebug/
12+
[Dd]ebugPublic/
13+
[Rr]elease/
14+
x64/
15+
build/
16+
bld/
17+
[Bb]in/
18+
[Oo]bj/
19+
_build/
20+
_build32/
21+
_build64/
22+
*.inc
23+
24+
# Test results
25+
*-FAILED.png
26+
27+
# MSTest test Results
28+
[Tt]est[Rr]esult*/
29+
[Bb]uild[Ll]og.*
30+
[Tt]esting/
31+
32+
#NUNIT
33+
*.VisualState.xml
34+
TestResult.xml
35+
36+
# Build Results of an ATL Project
37+
[Dd]ebugPS/
38+
[Rr]eleasePS/
39+
dlldata.c
40+
41+
*_i.c
42+
*_p.c
43+
*_i.h
44+
*.ilk
45+
*.meta
46+
*.obj
47+
*.pch
48+
*.pdb
49+
*.pgc
50+
*.pgd
51+
*.rsp
52+
*.sbr
53+
*.tlb
54+
*.tli
55+
*.tlh
56+
*.tmp
57+
*.tmp_proj
58+
*.log
59+
*.vspscc
60+
*.vssscc
61+
.builds
62+
*.pidb
63+
*.svclog
64+
*.scc
65+
66+
# Chutzpah Test files
67+
_Chutzpah*
68+
69+
# Visual C++ cache files
70+
ipch/
71+
*.aps
72+
*.ncb
73+
*.opensdf
74+
*.sdf
75+
*.cachefile
76+
77+
# Visual Studio profiler
78+
*.psess
79+
*.vsp
80+
*.vspx
81+
82+
# TFS 2012 Local Workspace
83+
$tf/
84+
85+
# Guidance Automation Toolkit
86+
*.gpState
87+
88+
# ReSharper is a .NET coding add-in
89+
_ReSharper*/
90+
*.[Rr]e[Ss]harper
91+
*.DotSettings.user
92+
93+
# JustCode is a .NET coding addin-in
94+
.JustCode
95+
96+
# TeamCity is a build add-in
97+
_TeamCity*
98+
99+
# DotCover is a Code Coverage Tool
100+
*.dotCover
101+
102+
# NCrunch
103+
*.ncrunch*
104+
_NCrunch_*
105+
.*crunch*.local.xml
106+
107+
# MightyMoose
108+
*.mm.*
109+
AutoTest.Net/
110+
111+
# Web workbench (sass)
112+
.sass-cache/
113+
114+
# Installshield output folder
115+
[Ee]xpress/
116+
117+
# DocProject is a documentation generator add-in
118+
DocProject/buildhelp/
119+
DocProject/Help/*.HxT
120+
DocProject/Help/*.HxC
121+
DocProject/Help/*.hhc
122+
DocProject/Help/*.hhk
123+
DocProject/Help/*.hhp
124+
DocProject/Help/Html2
125+
DocProject/Help/html
126+
127+
# Click-Once directory
128+
publish/
129+
130+
# Publish Web Output
131+
*.[Pp]ublish.xml
132+
*.azurePubxml
133+
134+
# NuGet Packages Directory
135+
packages/
136+
## TODO: If the tool you use requires repositories.config uncomment the next line
137+
#!packages/repositories.config
138+
139+
# Enable "build/" folder in the NuGet Packages folder since NuGet packages use it for MSBuild targets
140+
# This line needs to be after the ignore of the build folder (and the packages folder if the line above has been uncommented)
141+
!packages/build/
142+
143+
# Windows Azure Build Output
144+
csx/
145+
*.build.csdef
146+
147+
# Windows Store app package directory
148+
AppPackages/
149+
150+
# Others
151+
.idea/
152+
.vs/
153+
.vscode/
154+
sql/
155+
*.Cache
156+
ClientBin/
157+
[Ss]tyle[Cc]op.*
158+
~$*
159+
*~
160+
*.dbmdl
161+
*.dbproj.schemaview
162+
*.pfx
163+
*.publishsettings
164+
node_modules/
165+
166+
# RIA/Silverlight projects
167+
Generated_Code/
168+
169+
# Backup & report files from converting an old project file to a newer
170+
# Visual Studio version. Backup files are not needed, because we have git ;-)
171+
_UpgradeReport_Files/
172+
Backup*/
173+
UpgradeLog*.XML
174+
UpgradeLog*.htm
175+
176+
# SQL Server files
177+
*.mdf
178+
*.ldf
179+
180+
# Business Intelligence projects
181+
*.rdl.data
182+
*.bim.layout
183+
*.bim_*.settings
184+
185+
# Microsoft Fakes
186+
FakesAssemblies/
187+
188+
# litehtml specific files
189+
test/visual-test.sh
190+

CMakeLists.txt

Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
cmake_minimum_required(VERSION 3.11)
2+
3+
project(litehtml-test LANGUAGES C CXX)
4+
5+
add_subdirectory(${LITEHTML_PATH} litehtml)
6+
7+
set(TESTS_SRC
8+
encodings_test.cpp
9+
# codepoint_test.cpp
10+
# tstring_view_test.cpp
11+
# url_test.cpp
12+
# url_path_test.cpp
13+
render_test.cpp
14+
fonts.h
15+
fonts.cpp
16+
${LITEHTML_PATH}/containers/cairo/cairo_images_cache.h
17+
${LITEHTML_PATH}/containers/cairo/cairo_borders.cpp
18+
${LITEHTML_PATH}/containers/cairo/cairo_borders.h
19+
${LITEHTML_PATH}/containers/cairo/container_cairo.cpp
20+
${LITEHTML_PATH}/containers/cairo/container_cairo.h
21+
${LITEHTML_PATH}/containers/cairo/container_cairo_pango.cpp
22+
${LITEHTML_PATH}/containers/cairo/container_cairo_pango.h
23+
${LITEHTML_PATH}/containers/cairo/render2png.cpp
24+
${LITEHTML_PATH}/containers/cairo/render2png.h
25+
)
26+
27+
# additional warnings
28+
add_compile_options(-Wall -Wextra -Wpedantic)
29+
30+
# Tests
31+
32+
if (LITEHTML_BUILD_RENDER2PNG)
33+
set(RENDER2PNG_NAME render2png)
34+
35+
find_package(PkgConfig REQUIRED)
36+
37+
pkg_check_modules(RENDER2PNG_LIBS REQUIRED gdk-3.0 cairo pango pangocairo fontconfig)
38+
39+
add_executable(
40+
${RENDER2PNG_NAME}
41+
render2png_main.cpp
42+
${LITEHTML_PATH}/containers/cairo/cairo_borders.cpp
43+
${LITEHTML_PATH}/containers/cairo/cairo_borders.h
44+
${LITEHTML_PATH}/containers/cairo/container_cairo.cpp
45+
${LITEHTML_PATH}/containers/cairo/container_cairo.h
46+
${LITEHTML_PATH}/containers/cairo/container_cairo_pango.cpp
47+
${LITEHTML_PATH}/containers/cairo/container_cairo_pango.h
48+
${LITEHTML_PATH}/containers/cairo/render2png.cpp
49+
${LITEHTML_PATH}/containers/cairo/cairo_images_cache.h
50+
${LITEHTML_PATH}/test/fonts.h
51+
${LITEHTML_PATH}/test/fonts.cpp
52+
)
53+
54+
set_target_properties(${RENDER2PNG_NAME} PROPERTIES
55+
CXX_STANDARD 17
56+
C_STANDARD 99
57+
PUBLIC_HEADER "${HEADER_LITEHTML}"
58+
)
59+
60+
target_include_directories(
61+
${RENDER2PNG_NAME}
62+
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/containers/cairo
63+
PRIVATE ${RENDER2PNG_LIBS_INCLUDE_DIRS}
64+
)
65+
66+
target_link_options(${RENDER2PNG_NAME} PRIVATE ${RENDER2PNG_LIBS_LDFLAGS})
67+
target_link_libraries(${RENDER2PNG_NAME} PRIVATE ${PROJECT_NAME} ${RENDER2PNG_LIBS_LIBRARIES})
68+
69+
endif ()
70+
71+
option(EXTERNAL_GTEST "Use external GoogleTest instead of fetching from GitHub" OFF)
72+
73+
if (EXTERNAL_GTEST)
74+
link_libraries("-Wl,--copy-dt-needed-entries")
75+
else()
76+
include(FetchContent)
77+
FetchContent_Declare(
78+
googletest
79+
URL https://github.com/google/googletest/archive/609281088cfefc76f9d0ce82e1ff6c30cc3591e5.zip
80+
)
81+
# For Windows: Prevent overriding the parent project's compiler/linker settings
82+
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
83+
FetchContent_GetProperties(googletest)
84+
if(NOT googletest_POPULATED)
85+
FetchContent_Populate(googletest)
86+
add_subdirectory(${googletest_SOURCE_DIR} ${googletest_BINARY_DIR})
87+
endif()
88+
endif()
89+
90+
enable_testing()
91+
92+
find_package(PkgConfig REQUIRED)
93+
pkg_check_modules(TEST_LIBS REQUIRED gdk-3.0 cairo pango pangocairo fontconfig)
94+
95+
add_executable(
96+
${PROJECT_NAME}
97+
${TESTS_SRC}
98+
)
99+
100+
set_target_properties(${PROJECT_NAME} PROPERTIES
101+
CXX_STANDARD 17
102+
C_STANDARD 99
103+
)
104+
105+
target_include_directories(
106+
${PROJECT_NAME}
107+
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
108+
PRIVATE ${TEST_LIBS_INCLUDE_DIRS}
109+
PRIVATE ${LITEHTML_PATH}/include
110+
PRIVATE ${LITEHTML_PATH}/src
111+
PRIVATE ${LITEHTML_PATH}/containers/cairo
112+
)
113+
114+
target_link_options(${PROJECT_NAME} PRIVATE ${TEST_LIBS_LDFLAGS} -Llitehtml)
115+
target_link_libraries(
116+
${PROJECT_NAME}
117+
gtest_main
118+
${TEST_LIBS_LIBRARIES}
119+
litehtml
120+
)
121+
122+
include(GoogleTest)
123+
gtest_discover_tests(${PROJECT_NAME} WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})

render_test.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
#include "render2png.h"
99
#include "litehtml/html.h"
1010

11+
namespace fs = std::filesystem;
12+
1113
std::vector<std::string> find_htm_files(std::string dir);
1214
bool test(std::string filename);
1315

@@ -88,7 +90,7 @@ int main(int argc, char* argv[])
8890

8991
#include <gtest/gtest.h>
9092

91-
std::string test_dir = "../test/render"; // ctest is run from litehtml/build
93+
std::string test_dir = fs::path(__FILE__).parent_path() / "render";
9294

9395
using render_test = testing::TestWithParam<std::string>;
9496

0 commit comments

Comments
 (0)