From 7046ab9b4a0d4e70e3e717ec48727ad44d0f7604 Mon Sep 17 00:00:00 2001 From: blueloveTH Date: Thu, 28 Sep 2023 01:36:55 +0800 Subject: [PATCH] Update CMakeLists.txt --- CMakeLists.txt | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1eddf04b..fcd696e5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -35,8 +35,17 @@ if(PK_USE_BOX2D) add_definitions(-DPK_USE_BOX2D) endif() -option(PK_BUILD_SHARED_LIB "Build shared library" OFF) -option(PK_BUILD_STATIC_LIB "Build static library" OFF) +# PK_IS_MAIN determines whether the project is being used from root +# or if it is added as a dependency (through add_subdirectory for example). +if ("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}") + set(PK_IS_MAIN TRUE) + option(PK_BUILD_SHARED_LIB "Build shared library" OFF) + option(PK_BUILD_STATIC_LIB "Build static library" OFF) +else() + set(PK_IS_MAIN FALSE) + option(PK_BUILD_SHARED_LIB "Build shared library" OFF) + option(PK_BUILD_STATIC_LIB "Build static library" ON) +endif() option(PK_EXPORT_CXX_SYMBOLS "Export C++ symbols" OFF)