Update CMake to a more modern module management system and create simple test based on imgui null example

This commit is contained in:
Leonardo Mariscal
2019-07-31 19:30:36 -05:00
parent ccf494d1c3
commit 14e8be9af1
8 changed files with 93 additions and 47 deletions

View File

@@ -1,20 +1,15 @@
Project(cimgui)
cmake_minimum_required(VERSION 2.8)
cmake_minimum_required(VERSION 3.1)
project(cimgui)
#general settings
include_directories(imgui)
add_definitions("-DIMGUI_DISABLE_OBSOLETE_FUNCTIONS=1")
include_directories(.)
set(IMGUI_SOURCES ./cimgui.cpp ./imgui/imgui.cpp ./imgui/imgui_draw.cpp ./imgui/imgui_demo.cpp ./imgui/imgui_widgets.cpp)
set(IMGUI_LIBRARIES )
if (WIN32)
add_definitions("-DIMGUI_IMPL_API=extern \"C\" __declspec\(dllexport\)")
else(WIN32)
add_definitions("-DIMGUI_IMPL_API=extern \"C\" ")
endif(WIN32)
file(GLOB IMGUI_SOURCES
cimgui.cpp
imgui/imgui.cpp
imgui/imgui_draw.cpp
imgui/imgui_demo.cpp
imgui/imgui_widgets.cpp
)
set(IMGUI_STATIC "no" CACHE STRING "Build as a static library")
@@ -25,12 +20,27 @@ else (IMGUI_STATIC)
add_library(cimgui SHARED ${IMGUI_SOURCES})
endif (IMGUI_STATIC)
target_link_libraries(cimgui ${IMGUI_LIBRARIES})
target_compile_definitions(cimgui PUBLIC IMGUI_DISABLE_OBSOLETE_FUNCTIONS=1)
if (WIN32)
target_compile_definitions(cimgui PUBLIC IMGUI_IMPL_API="extern \"C\" __declspec\(dllexport\)")
else (WIN32)
target_compile_definitions(cimgui PUBLIC IMGUI_IMPL_API="extern \"C\" ")
endif (WIN32)
target_include_directories(cimgui PUBLIC ${CMAKE_SOURCE_DIR})
target_include_directories(cimgui PUBLIC ${CMAKE_SOURCE_DIR}/imgui)
set_target_properties(cimgui PROPERTIES PREFIX "")
#install
install(TARGETS cimgui
RUNTIME DESTINATION .
LIBRARY DESTINATION .
ARCHIVE DESTINATION .
)
RUNTIME DESTINATION .
LIBRARY DESTINATION .
ARCHIVE DESTINATION .
)
#test
set(CIMGUI_TEST "no" CACHE STRING "Enable compilation of a test unit based on imgui null")
if (CIMGUI_TEST)
add_subdirectory(test)
endif ()