Skip to content

Commit

Permalink
add auto config with cmake
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangjipeng committed Jul 15, 2024
1 parent 4b249ba commit c281e69
Show file tree
Hide file tree
Showing 5 changed files with 133 additions and 28 deletions.
81 changes: 80 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,27 @@ project(picasso LANGUAGES C CXX ASM HOMEPAGE_URL https://onecoolx.github.io/pica
set(BUILD_SHARED_LIBS ON) # build shared library, OFF for static

set(PROJECT_ROOT ${CMAKE_CURRENT_LIST_DIR})
set(PROJECT_OUT ${CMAKE_CURRENT_BINARY_DIR})

set(VERSION_INFO 2.8.0)
set(VERSION_MAJOR 2)
set(VERSION_MINOR 8)
set(VERSION_MICRO 0)
set(VERSION_INFO ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_MICRO})

option(OPT_FORMAT_ABGR "Pixel format ABGR support." ON)
option(OPT_FORMAT_ARGB "Pixel format ARGB support." ON)
option(OPT_FORMAT_BGRA "Pixel format BGRA support." ON)
option(OPT_FORMAT_RGBA "Pixel format RGBA support." ON)
option(OPT_FORMAT_RGB "Pixel format RGB support." ON)
option(OPT_FORMAT_BGR "Pixel format BGR support." ON)
option(OPT_FORMAT_RGB565 "Pixel format RGB565 support." ON)
option(OPT_FORMAT_RGB555 "Pixel format RGB555 support." ON)

option(OPT_FAST_COPY "Build Fast Memory Copy used support." ON)
option(OPT_FREE_TYPE2 "Build FreeType2 is support." OFF)
option(OPT_FONT_CONFIG "Build FontConfig is support." OFF)
option(OPT_LOW_MEMORY "Build Low Memory used support." OFF)
option(OPT_SYSTEM_MALLOC "Build System Memory Allocator (new/delete/malloc/free/realloc/calloc) used support." OFF)

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

include(CheckIncludeFile)
check_include_file(stdint.h HAVE_STDINT_H)

if (OPT_FORMAT_ABGR)
set(ENABLE_FORMAT_ABGR 1)
endif(OPT_FORMAT_ABGR)

if (OPT_FORMAT_ARGB)
set(ENABLE_FORMAT_ARGB 1)
endif(OPT_FORMAT_ARGB)

if (OPT_FORMAT_BGRA)
set(ENABLE_FORMAT_BGRA 1)
endif(OPT_FORMAT_BGRA)

if (OPT_FORMAT_RGBA)
set(ENABLE_FORMAT_RGBA 1)
endif(OPT_FORMAT_RGBA)

if (OPT_FORMAT_RGB)
set(ENABLE_FORMAT_RGB 1)
endif(OPT_FORMAT_RGB)

if (OPT_FORMAT_BGR)
set(ENABLE_FORMAT_BGR 1)
endif(OPT_FORMAT_BGR)

if (OPT_FORMAT_RGB565)
set(ENABLE_FORMAT_RGB565 1)
endif(OPT_FORMAT_RGB565)

if (OPT_FORMAT_RGB555)
set(ENABLE_FORMAT_RGB555 1)
endif(OPT_FORMAT_RGB555)

if (OPT_FAST_COPY)
set(ENABLE_FAST_COPY 1)
endif(OPT_FAST_COPY)

if (OPT_FREE_TYPE2)
set(ENABLE_FREE_TYPE2 1)
endif(OPT_FREE_TYPE2)

if (OPT_FONT_CONFIG)
set(ENABLE_FONT_CONFIG 1)
endif(OPT_FONT_CONFIG)

if (OPT_LOW_MEMORY)
set(ENABLE_LOW_MEMORY 1)
endif(OPT_LOW_MEMORY)

if (OPT_SYSTEM_MALLOC)
set(ENABLE_SYSTEM_MALLOC 1)
endif(OPT_SYSTEM_MALLOC)

configure_file(
"${PROJECT_ROOT}/build/pconfig.h.in"
"${PROJECT_OUT}/include/pconfig.h"
)

23 changes: 0 additions & 23 deletions build/pconfig.h

This file was deleted.

46 changes: 46 additions & 0 deletions build/pconfig.h.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#ifndef _CONFIGURATION_HEADER_PCONFIG_H_
#define _CONFIGURATION_HEADER_PCONFIG_H_

/* Define if Fast memory copy is supported. */
#cmakedefine ENABLE_FAST_COPY @ENABLE_FAST_COPY@

/* Define if ABGR color format is supported. */
#cmakedefine ENABLE_FORMAT_ABGR @ENABLE_FORMAT_ABGR@

/* Define if ARGB color format is supported. */
#cmakedefine ENABLE_FORMAT_ARGB @ENABLE_FORMAT_ARGB@

/* Define if BGRA color format is supported. */
#cmakedefine ENABLE_FORMAT_BGRA @ENABLE_FORMAT_BGRA@

/* Define if RGBA color format is supported. */
#cmakedefine ENABLE_FORMAT_RGBA @ENABLE_FORMAT_RGBA@

/* Define if BGR color format is supported. */
#cmakedefine ENABLE_FORMAT_BGR @ENABLE_FORMAT_BGR@

/* Define if RGB color format is supported. */
#cmakedefine ENABLE_FORMAT_RGB @ENABLE_FORMAT_RGB@

/* Define if RGB555 color format is supported. */
#cmakedefine ENABLE_FORMAT_RGB555 @ENABLE_FORMAT_RGB555@

/* Define if RGB565 color format is supported. */
#cmakedefine ENABLE_FORMAT_RGB565 @ENABLE_FORMAT_RGB565@

/* Define if FreeType2 is supported. */
#cmakedefine ENABLE_FREE_TYPE2 @ENABLE_FREE_TYPE2@

/* Define if FontConfig is supported. */
#cmakedefine ENABLE_FONT_CONFIG @ENABLE_FONT_CONFIG@

/* Define if Low memory is supported. */
#cmakedefine ENABLE_LOW_MEMORY @ENABLE_LOW_MEMORY@

/* Define if System memory allocator is supported. */
#cmakedefine ENABLE_SYSTEM_MALLOC @ENABLE_SYSTEM_MALLOC@

/* Have stdint.h */
#cmakedefine HAVE_STDINT_H @HAVE_STDINT_H@

#endif /*_CONFIGURATION_HEADER_PCONFIG_H_*/
5 changes: 4 additions & 1 deletion build_linux.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
#!/bin/sh

mkdir proj
if [ ! -d "./proj" ]; then
mkdir proj
fi

cd proj

build_type="-DCMAKE_BUILD_TYPE=Debug"
Expand Down
6 changes: 3 additions & 3 deletions src/src.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@

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

include_directories(${PROJECT_ROOT}/build
${PROJECT_ROOT}/include
include_directories(${PROJECT_ROOT}/include
${PROJECT_ROOT}/src/include
${PROJECT_ROOT}/src
${PROJECT_ROOT}/src/gfx
${PROJECT_ROOT}/src/simd)
${PROJECT_ROOT}/src/simd
${PROJECT_OUT}/include)

set(LIB_NAME picasso2_sw)

Expand Down

0 comments on commit c281e69

Please sign in to comment.