diff --git a/CMakeLists.txt b/CMakeLists.txt index 9d3edba..a571ed5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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}) @@ -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) @@ -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) diff --git a/build/defines.cmake b/build/defines.cmake index 3ab8d0d..88384c6 100644 --- a/build/defines.cmake +++ b/build/defines.cmake @@ -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) diff --git a/src/src.cmake b/src/src.cmake index 9b1cff9..23f16bc 100644 --- a/src/src.cmake +++ b/src/src.cmake @@ -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)