Skip to content

Commit

Permalink
fix static lib build
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangjipeng committed Sep 13, 2024
1 parent cba72bd commit b217ebe
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 19 deletions.
19 changes: 2 additions & 17 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ cmake_minimum_required(VERSION 3.16.0)

project(picasso LANGUAGES C CXX ASM HOMEPAGE_URL https://onecoolx.github.io/picasso/)

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})

Expand All @@ -13,7 +11,6 @@ set(VERSION_MICRO 0)
set(VERSION_INFO ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_MICRO})

option(BUILD_SHARED_LIBS "Build shared libraries (default)" ON)
option(BUILD_STATIC_LIBS "Build static libraries" OFF)

option(OPT_FORMAT_ABGR "Pixel format ABGR support." ON)
option(OPT_FORMAT_ARGB "Pixel format ARGB support." ON)
Expand All @@ -34,22 +31,10 @@ option(OPT_EXTENSIONS "Build extension libraries." ON)

option(OPT_TESTS "Build test apps" ON)
option(OPT_DEMOS "Build example demos" ON)
option(OPT_UNITTEST "Build Unit tests" OFF)
option(OPT_UNITTEST "Build unit tests" OFF)

if (NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Debug CACHE STRING "Build Type" FORCE)
endif()

if (NOT BUILD_SHARED_LIBS AND NOT BUILD_STATIC_LIBS)
set(BUILD_STATIC_LIBS ON)
endif()

if (BUILD_SHARED_LIBS)
set(BUILD_SHARED_LIBS ON)
endif()

if (BUILD_STATIC_LIBS)
set(BUILD_STATIC_LIBS ON)
set(CMAKE_BUILD_TYPE Debug CACHE STRING "Build type" FORCE)
endif()

include (${CMAKE_CURRENT_LIST_DIR}/build/configs.cmake)
Expand Down
4 changes: 3 additions & 1 deletion build/defines.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@

if (WIN32)
add_compile_definitions(WIN32)
add_compile_definitions(DLL_EXPORT)
if (BUILD_SHARED_LIBS)
add_compile_definitions(DLL_EXPORT)
endif()
add_compile_definitions(ENABLE_FAST_COPY=1)
add_compile_definitions(ENABLE_SYSTEM_MALLOC=1)
add_compile_definitions(__SSE2__=1)
Expand Down
8 changes: 7 additions & 1 deletion src/src.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,13 @@ elseif (APPLE)
endif()

add_definitions(-DEXPORT)
add_library(${LIB_NAME} ${SOURCES})
if (BUILD_SHARED_LIBS)
set(BUILD_LIBS_TYPE SHARED)
else()
set(BUILD_LIBS_TYPE STATIC)
endif()

add_library(${LIB_NAME} ${BUILD_LIBS_TYPE} ${SOURCES})
install(TARGETS ${LIB_NAME} LIBRARY DESTINATION lib ARCHIVE DESTINATION lib RUNTIME DESTINATION bin)

if (UNIX AND NOT APPLE)
Expand Down

0 comments on commit b217ebe

Please sign in to comment.