Skip to content

Commit 3320aa4

Browse files
Fixes for compilation for many platforms.
Split gubmo and litehtml to different CMake projects with different compile languages. Move 'src/strings.h' to 'src/gumbo/visualc/include/strings.h'. Remove '../src/' in '#include' directive in litehtml.h and add target_include_directories() in CMake project. Set C/C++ standard flags by set_target_properties() in CMake project. Do not set build type and C/C++ compiler flags in library project.
1 parent a45d5d5 commit 3320aa4

File tree

4 files changed

+88
-74
lines changed

4 files changed

+88
-74
lines changed

CMakeLists.txt

Lines changed: 51 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -1,74 +1,58 @@
11
cmake_minimum_required(VERSION 2.8)
22

3-
project(litehtml)
4-
5-
if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
6-
message(STATUS "No build type selected, default to Release")
7-
set(CMAKE_BUILD_TYPE "Release")
8-
endif()
9-
10-
if(NOT MSVC)
11-
set(CMAKE_CXX_FLAGS "-std=c++11")
12-
set(CMAKE_CXX_FLAGS_DEBUG "-O0 -DDEBUG -g")
13-
set(CMAKE_C_FLAGS_DEBUG "-std=c99 -O0 -DDEBUG -g")
14-
set(CMAKE_CXX_FLAGS_RELEASE "-O3")
15-
set(CMAKE_C_FLAGS_RELEASE "-std=c99 -O3")
16-
endif()
17-
18-
set(SOURCE_LITEHTML src/background.cpp
19-
src/box.cpp
20-
src/context.cpp
21-
src/css_length.cpp
22-
src/css_selector.cpp
23-
src/document.cpp
24-
src/el_anchor.cpp
25-
src/el_base.cpp
26-
src/el_before_after.cpp
27-
src/el_body.cpp
28-
src/el_break.cpp
29-
src/el_cdata.cpp
30-
src/el_comment.cpp
31-
src/el_div.cpp
32-
src/element.cpp
33-
src/el_font.cpp
34-
src/el_image.cpp
35-
src/el_link.cpp
36-
src/el_para.cpp
37-
src/el_script.cpp
38-
src/el_space.cpp
39-
src/el_style.cpp
40-
src/el_table.cpp
41-
src/el_td.cpp
42-
src/el_text.cpp
43-
src/el_title.cpp
44-
src/el_tr.cpp
45-
src/html.cpp
46-
src/html_tag.cpp
47-
src/iterators.cpp
48-
src/media_query.cpp
49-
src/style.cpp
50-
src/stylesheet.cpp
51-
src/table.cpp
52-
src/utf8_strings.cpp
53-
src/web_color.cpp
3+
project(litehtml CXX)
4+
5+
add_subdirectory(src/gumbo)
6+
7+
set(SOURCE_LITEHTML
8+
src/background.cpp
9+
src/box.cpp
10+
src/context.cpp
11+
src/css_length.cpp
12+
src/css_selector.cpp
13+
src/document.cpp
14+
src/el_anchor.cpp
15+
src/el_base.cpp
16+
src/el_before_after.cpp
17+
src/el_body.cpp
18+
src/el_break.cpp
19+
src/el_cdata.cpp
20+
src/el_comment.cpp
21+
src/el_div.cpp
22+
src/element.cpp
23+
src/el_font.cpp
24+
src/el_image.cpp
25+
src/el_link.cpp
26+
src/el_para.cpp
27+
src/el_script.cpp
28+
src/el_space.cpp
29+
src/el_style.cpp
30+
src/el_table.cpp
31+
src/el_td.cpp
32+
src/el_text.cpp
33+
src/el_title.cpp
34+
src/el_tr.cpp
35+
src/html.cpp
36+
src/html_tag.cpp
37+
src/iterators.cpp
38+
src/media_query.cpp
39+
src/style.cpp
40+
src/stylesheet.cpp
41+
src/table.cpp
42+
src/utf8_strings.cpp
43+
src/web_color.cpp
5444
)
5545

56-
set(SOURCE_GUMBO src/gumbo/attribute.c
57-
src/gumbo/char_ref.c
58-
src/gumbo/error.c
59-
src/gumbo/parser.c
60-
src/gumbo/string_buffer.c
61-
src/gumbo/string_piece.c
62-
src/gumbo/tag.c
63-
src/gumbo/tokenizer.c
64-
src/gumbo/utf8.c
65-
src/gumbo/util.c
66-
src/gumbo/vector.c
67-
)
46+
add_library(${PROJECT_NAME} ${SOURCE_LITEHTML})
6847

69-
add_library(litehtml STATIC ${SOURCE_LITEHTML} ${SOURCE_GUMBO})
48+
set_target_properties(${PROJECT_NAME} PROPERTIES
49+
CXX_STANDARD 11
50+
C_STANDARD 99
51+
)
7052

71-
if(WIN32)
72-
target_include_directories(litehtml PUBLIC src/gumbo)
73-
endif()
53+
# Export litehtml includes.
54+
target_include_directories(${PROJECT_NAME} PUBLIC src)
55+
target_include_directories(${PROJECT_NAME} PUBLIC include)
7456

57+
# Gumbo
58+
target_link_libraries(${PROJECT_NAME} PUBLIC gumbo)

include/litehtml.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
#ifndef LITEHTML_H
22
#define LITEHTML_H
33

4-
#include "../src/html.h"
5-
#include "../src/document.h"
6-
#include "../src/html_tag.h"
7-
#include "../src/stylesheet.h"
8-
#include "../src/stylesheet.h"
9-
#include "../src/element.h"
10-
#include "../src/html_tag.h"
4+
#include "html.h"
5+
#include "document.h"
6+
#include "html_tag.h"
7+
#include "stylesheet.h"
8+
#include "stylesheet.h"
9+
#include "element.h"
10+
#include "html_tag.h"
1111

1212
#endif // LITEHTML_H

src/gumbo/CMakeLists.txt

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
cmake_minimum_required(VERSION 2.8)
2+
3+
project(gumbo C)
4+
5+
set(SOURCE_GUMBO
6+
attribute.c
7+
char_ref.c
8+
error.c
9+
parser.c
10+
string_buffer.c
11+
string_piece.c
12+
tag.c
13+
tokenizer.c
14+
utf8.c
15+
util.c
16+
vector.c
17+
)
18+
19+
add_library(${PROJECT_NAME} ${SOURCE_GUMBO})
20+
21+
set_target_properties(${PROJECT_NAME} PROPERTIES
22+
C_STANDARD 99
23+
)
24+
25+
if(MSVC)
26+
target_include_directories(${PROJECT_NAME} PRIVATE visualc/include)
27+
endif()
28+
29+
# Export gumbo includes.
30+
target_include_directories(${PROJECT_NAME} PUBLIC ${PROJECT_SOURCE_DIR})
File renamed without changes.

0 commit comments

Comments
 (0)