Browse Source

cmake: by default, disable install target when building SDL as a subproject

Anonymous Maarten 2 years ago
parent
commit
d63a699e01
1 changed files with 7 additions and 1 deletions
  1. 7 1
      CMakeLists.txt

+ 7 - 1
CMakeLists.txt

@@ -5,6 +5,12 @@ endif()
 cmake_minimum_required(VERSION 3.0.0)
 project(SDL2 C CXX)
 
+if(CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR)
+  set(SDL2_SUBPROJECT OFF)
+else()
+  set(SDL2_SUBPROJECT ON)
+endif()
+
 if (HAIKU)
   set(LINKER_LANGUAGE CXX)
 endif()
@@ -414,7 +420,7 @@ endforeach()
 
 # Allow some projects to be built conditionally.
 set_option(SDL2_DISABLE_SDL2MAIN   "Disable building/installation of SDL2main" OFF)
-set_option(SDL2_DISABLE_INSTALL    "Disable installation of SDL2" OFF)
+set_option(SDL2_DISABLE_INSTALL    "Disable installation of SDL2" ${SDL2_SUBPROJECT})
 set_option(SDL2_DISABLE_UNINSTALL  "Disable uninstallation of SDL2" OFF)
 
 option_string(SDL_ASSERTIONS "Enable internal sanity checks (auto/disabled/release/enabled/paranoid)" "auto")