From 201fdf0cbee800c11c374145695df3c40472db98 Mon Sep 17 00:00:00 2001 From: Georgi Gerganov Date: Mon, 18 Jan 2021 20:44:27 +0200 Subject: [PATCH] cmake : use BUILD_SHARED_LIBS --- CMakeLists.txt | 9 +++------ examples/CMakeLists.txt | 4 ++-- examples/third-party/imgui/CMakeLists.txt | 8 ++++---- src/CMakeLists.txt | 4 ++-- 4 files changed, 11 insertions(+), 14 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ef499a4..d09cad7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,18 +14,15 @@ endif() if (EMSCRIPTEN) set(GGWAVE_SUPPORT_SDL2_DEFAULT ON) - set(GGWAVE_LIBRARY_TYPE STATIC) + set(BUILD_SHARED_LIBS_DEFAULT OFF) else() set(GGWAVE_SUPPORT_SDL2_DEFAULT ON) - if (BUILD_SHARED_LIBS) - set(GGWAVE_LIBRARY_TYPE SHARED) - else () - set(GGWAVE_LIBRARY_TYPE STATIC) - endif() + set(BUILD_SHARED_LIBS_DEFAULT ON) endif() # options +option(BUILD_SHARED_LIBS "ggwave: build shared libs" ${BUILD_SHARED_LIBS_DEFAULT}) option(USE_FINDSDL2 "ggwave: use the FindSDL2.cmake script" OFF) option(GGWAVE_ALL_WARNINGS "ggwave: enable all compiler warnings" ON) diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 874878d..9f4145c 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -37,7 +37,7 @@ add_subdirectory(third-party) # helper libraries -add_library(ggwave-common ${GGWAVE_LIBRARY_TYPE} +add_library(ggwave-common ggwave-common.cpp ) @@ -48,7 +48,7 @@ target_link_libraries(ggwave-common PRIVATE if (GGWAVE_SUPPORT_SDL2) # ggwave-common-sdl2 - add_library(ggwave-common-sdl2 ${GGWAVE_LIBRARY_TYPE} + add_library(ggwave-common-sdl2 ggwave-common-sdl2.cpp ) diff --git a/examples/third-party/imgui/CMakeLists.txt b/examples/third-party/imgui/CMakeLists.txt index 0c57bb3..ef64c0a 100644 --- a/examples/third-party/imgui/CMakeLists.txt +++ b/examples/third-party/imgui/CMakeLists.txt @@ -12,7 +12,7 @@ else (APPLE) unset(ADDITIONAL_LIBRARIES) endif (APPLE) -add_library(imgui ${GGWAVE_LIBRARY_TYPE} +add_library(imgui imgui/imgui.cpp imgui/imgui_draw.cpp imgui/imgui_demo.cpp @@ -36,7 +36,7 @@ if (GGWAVE_SUPPORT_SDL2) find_package(PkgConfig REQUIRED) pkg_search_module(SDL2 REQUIRED sdl2) - add_library(imgui-sdl2 ${GGWAVE_LIBRARY_TYPE} + add_library(imgui-sdl2 imgui/examples/libs/gl3w/GL/gl3w.c imgui-extra/imgui_impl.cpp imgui-extra/imgui_impl_sdl.cpp @@ -66,7 +66,7 @@ if (GGWAVE_SUPPORT_SDL2) ${ADDITIONAL_LIBRARIES} ) elseif (EMSCRIPTEN) - add_library(imgui-sdl2 ${GGWAVE_LIBRARY_TYPE} + add_library(imgui-sdl2 imgui-extra/imgui_impl.cpp imgui-extra/imgui_impl_sdl.cpp imgui-extra/imgui_impl_opengl3.cpp @@ -83,7 +83,7 @@ if (GGWAVE_SUPPORT_SDL2) else() find_package(OpenGL REQUIRED) - add_library(imgui-sdl2 ${GGWAVE_LIBRARY_TYPE} + add_library(imgui-sdl2 imgui/examples/libs/gl3w/GL/gl3w.c imgui-extra/imgui_impl.cpp imgui-extra/imgui_impl_sdl.cpp diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index ca0b3cc..6f42d13 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -2,7 +2,7 @@ set(TARGET ggwave) -add_library(${TARGET} ${GGWAVE_LIBRARY_TYPE} +add_library(${TARGET} ggwave.cpp ) @@ -11,7 +11,7 @@ target_include_directories(${TARGET} PUBLIC ../include ) -if (GGWAVE_LIBRARY_TYPE STREQUAL "SHARED") +if (BUILD_SHARED_LIBS) target_link_libraries(${TARGET} PUBLIC ${CMAKE_DL_LIBS} )