Skip to content

Commit c281e69

Browse files
author
zhangjipeng
committed
add auto config with cmake
1 parent 4b249ba commit c281e69

File tree

5 files changed

+133
-28
lines changed

5 files changed

+133
-28
lines changed

CMakeLists.txt

+80-1
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,27 @@ project(picasso LANGUAGES C CXX ASM HOMEPAGE_URL https://onecoolx.github.io/pica
55
set(BUILD_SHARED_LIBS ON) # build shared library, OFF for static
66

77
set(PROJECT_ROOT ${CMAKE_CURRENT_LIST_DIR})
8+
set(PROJECT_OUT ${CMAKE_CURRENT_BINARY_DIR})
89

9-
set(VERSION_INFO 2.8.0)
10+
set(VERSION_MAJOR 2)
11+
set(VERSION_MINOR 8)
12+
set(VERSION_MICRO 0)
13+
set(VERSION_INFO ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_MICRO})
14+
15+
option(OPT_FORMAT_ABGR "Pixel format ABGR support." ON)
16+
option(OPT_FORMAT_ARGB "Pixel format ARGB support." ON)
17+
option(OPT_FORMAT_BGRA "Pixel format BGRA support." ON)
18+
option(OPT_FORMAT_RGBA "Pixel format RGBA support." ON)
19+
option(OPT_FORMAT_RGB "Pixel format RGB support." ON)
20+
option(OPT_FORMAT_BGR "Pixel format BGR support." ON)
21+
option(OPT_FORMAT_RGB565 "Pixel format RGB565 support." ON)
22+
option(OPT_FORMAT_RGB555 "Pixel format RGB555 support." ON)
23+
24+
option(OPT_FAST_COPY "Build Fast Memory Copy used support." ON)
25+
option(OPT_FREE_TYPE2 "Build FreeType2 is support." OFF)
26+
option(OPT_FONT_CONFIG "Build FontConfig is support." OFF)
27+
option(OPT_LOW_MEMORY "Build Low Memory used support." OFF)
28+
option(OPT_SYSTEM_MALLOC "Build System Memory Allocator (new/delete/malloc/free/realloc/calloc) used support." OFF)
1029

1130
if (NOT CMAKE_BUILD_TYPE)
1231
set(CMAKE_BUILD_TYPE Debug CACHE STRING "Build Type" FORCE)
@@ -21,3 +40,63 @@ include (${CMAKE_CURRENT_LIST_DIR}/include/include.cmake)
2140
include (${CMAKE_CURRENT_LIST_DIR}/test/test.cmake)
2241
include (${CMAKE_CURRENT_LIST_DIR}/demos/demos.cmake)
2342

43+
include(CheckIncludeFile)
44+
check_include_file(stdint.h HAVE_STDINT_H)
45+
46+
if (OPT_FORMAT_ABGR)
47+
set(ENABLE_FORMAT_ABGR 1)
48+
endif(OPT_FORMAT_ABGR)
49+
50+
if (OPT_FORMAT_ARGB)
51+
set(ENABLE_FORMAT_ARGB 1)
52+
endif(OPT_FORMAT_ARGB)
53+
54+
if (OPT_FORMAT_BGRA)
55+
set(ENABLE_FORMAT_BGRA 1)
56+
endif(OPT_FORMAT_BGRA)
57+
58+
if (OPT_FORMAT_RGBA)
59+
set(ENABLE_FORMAT_RGBA 1)
60+
endif(OPT_FORMAT_RGBA)
61+
62+
if (OPT_FORMAT_RGB)
63+
set(ENABLE_FORMAT_RGB 1)
64+
endif(OPT_FORMAT_RGB)
65+
66+
if (OPT_FORMAT_BGR)
67+
set(ENABLE_FORMAT_BGR 1)
68+
endif(OPT_FORMAT_BGR)
69+
70+
if (OPT_FORMAT_RGB565)
71+
set(ENABLE_FORMAT_RGB565 1)
72+
endif(OPT_FORMAT_RGB565)
73+
74+
if (OPT_FORMAT_RGB555)
75+
set(ENABLE_FORMAT_RGB555 1)
76+
endif(OPT_FORMAT_RGB555)
77+
78+
if (OPT_FAST_COPY)
79+
set(ENABLE_FAST_COPY 1)
80+
endif(OPT_FAST_COPY)
81+
82+
if (OPT_FREE_TYPE2)
83+
set(ENABLE_FREE_TYPE2 1)
84+
endif(OPT_FREE_TYPE2)
85+
86+
if (OPT_FONT_CONFIG)
87+
set(ENABLE_FONT_CONFIG 1)
88+
endif(OPT_FONT_CONFIG)
89+
90+
if (OPT_LOW_MEMORY)
91+
set(ENABLE_LOW_MEMORY 1)
92+
endif(OPT_LOW_MEMORY)
93+
94+
if (OPT_SYSTEM_MALLOC)
95+
set(ENABLE_SYSTEM_MALLOC 1)
96+
endif(OPT_SYSTEM_MALLOC)
97+
98+
configure_file(
99+
"${PROJECT_ROOT}/build/pconfig.h.in"
100+
"${PROJECT_OUT}/include/pconfig.h"
101+
)
102+

build/pconfig.h

-23
This file was deleted.

build/pconfig.h.in

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
#ifndef _CONFIGURATION_HEADER_PCONFIG_H_
2+
#define _CONFIGURATION_HEADER_PCONFIG_H_
3+
4+
/* Define if Fast memory copy is supported. */
5+
#cmakedefine ENABLE_FAST_COPY @ENABLE_FAST_COPY@
6+
7+
/* Define if ABGR color format is supported. */
8+
#cmakedefine ENABLE_FORMAT_ABGR @ENABLE_FORMAT_ABGR@
9+
10+
/* Define if ARGB color format is supported. */
11+
#cmakedefine ENABLE_FORMAT_ARGB @ENABLE_FORMAT_ARGB@
12+
13+
/* Define if BGRA color format is supported. */
14+
#cmakedefine ENABLE_FORMAT_BGRA @ENABLE_FORMAT_BGRA@
15+
16+
/* Define if RGBA color format is supported. */
17+
#cmakedefine ENABLE_FORMAT_RGBA @ENABLE_FORMAT_RGBA@
18+
19+
/* Define if BGR color format is supported. */
20+
#cmakedefine ENABLE_FORMAT_BGR @ENABLE_FORMAT_BGR@
21+
22+
/* Define if RGB color format is supported. */
23+
#cmakedefine ENABLE_FORMAT_RGB @ENABLE_FORMAT_RGB@
24+
25+
/* Define if RGB555 color format is supported. */
26+
#cmakedefine ENABLE_FORMAT_RGB555 @ENABLE_FORMAT_RGB555@
27+
28+
/* Define if RGB565 color format is supported. */
29+
#cmakedefine ENABLE_FORMAT_RGB565 @ENABLE_FORMAT_RGB565@
30+
31+
/* Define if FreeType2 is supported. */
32+
#cmakedefine ENABLE_FREE_TYPE2 @ENABLE_FREE_TYPE2@
33+
34+
/* Define if FontConfig is supported. */
35+
#cmakedefine ENABLE_FONT_CONFIG @ENABLE_FONT_CONFIG@
36+
37+
/* Define if Low memory is supported. */
38+
#cmakedefine ENABLE_LOW_MEMORY @ENABLE_LOW_MEMORY@
39+
40+
/* Define if System memory allocator is supported. */
41+
#cmakedefine ENABLE_SYSTEM_MALLOC @ENABLE_SYSTEM_MALLOC@
42+
43+
/* Have stdint.h */
44+
#cmakedefine HAVE_STDINT_H @HAVE_STDINT_H@
45+
46+
#endif /*_CONFIGURATION_HEADER_PCONFIG_H_*/

build_linux.sh

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
#!/bin/sh
22

3-
mkdir proj
3+
if [ ! -d "./proj" ]; then
4+
mkdir proj
5+
fi
6+
47
cd proj
58

69
build_type="-DCMAKE_BUILD_TYPE=Debug"

src/src.cmake

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@
55

66
file(GLOB_RECURSE SOURCES ${PROJECT_ROOT}/src/*.cpp)
77

8-
include_directories(${PROJECT_ROOT}/build
9-
${PROJECT_ROOT}/include
8+
include_directories(${PROJECT_ROOT}/include
109
${PROJECT_ROOT}/src/include
1110
${PROJECT_ROOT}/src
1211
${PROJECT_ROOT}/src/gfx
13-
${PROJECT_ROOT}/src/simd)
12+
${PROJECT_ROOT}/src/simd
13+
${PROJECT_OUT}/include)
1414

1515
set(LIB_NAME picasso2_sw)
1616

0 commit comments

Comments
 (0)