From 8cbdca3344003e45e8d5c72e60d27471f910379d Mon Sep 17 00:00:00 2001 From: Sebastian Krzyszkowiak Date: Wed, 28 Nov 2018 18:19:52 +0100 Subject: [PATCH] cmake: add an option to build as a static library Useful when including cimgui as a subproject in another CMake project. --- CMakeLists.txt | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a5f4cf1..bc2e045 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -16,9 +16,15 @@ else(WIN32) add_definitions("-DIMGUI_IMPL_API=extern \"C\" ") endif(WIN32) +set(IMGUI_STATIC "no" CACHE STRING "Build as a static library") #add library and link -add_library(cimgui SHARED ${IMGUI_SOURCES}) +if (IMGUI_STATIC) + add_library(cimgui STATIC ${IMGUI_SOURCES}) +else (IMGUI_STATIC) + add_library(cimgui SHARED ${IMGUI_SOURCES}) +endif (IMGUI_STATIC) + target_link_libraries(cimgui ${IMGUI_LIBRARIES}) set_target_properties(cimgui PROPERTIES PREFIX "") @@ -26,5 +32,5 @@ set_target_properties(cimgui PROPERTIES PREFIX "") install(TARGETS cimgui RUNTIME DESTINATION . LIBRARY DESTINATION . - #ARCHIVE DESTINATION lib + ARCHIVE DESTINATION . )