Skip to content

Instantly share code, notes, and snippets.

@DustVoice
Created October 9, 2019 11:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DustVoice/bc08ad2b4db4d602fd747b8beb2f2934 to your computer and use it in GitHub Desktop.
Save DustVoice/bc08ad2b4db4d602fd747b8beb2f2934 to your computer and use it in GitHub Desktop.
cmake_minimum_required(VERSION 3.4)
project(CommuniCare_eV_Manager)
# =======================
# | Set project version |
# =======================
set(CommuniCare_eV_Manager_MAJOR 1)
set(CommuniCare_eV_Manager_MAJOR 12)
# ==========================
# | Compiler configuration |
# ==========================
include(CheckCXXCompilerFlag)
CHECK_CXX_COMPILER_FLAG("-std=c++14" COMPILER_SUPPORTS_CXX14)
if(COMPILER_SUPPORTS_CXX14)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14")
set(USER_CXX_VERSION "C++14")
else()
message(WARNING "This software needs a compiler that supports c++14 (-std=c++14) in order to work properly. Continuing anyways, which may lead to unexpected behaviour")
endif()
# =============
# | JUCE_PATH |
# =============
if (NOT DEFINED JUCE_PATH)
if (NOT DEFINED ENV{JUCE_PATH})
message(FATAL_ERROR "$JUCE_PATH not defined!
Please either pass the path to your JUCE modules directory directly, or export it!
Example 1:
cmake -DJUCE_PATH=~/Tools/JUCE/moudles ..
Example 2:
export JUCE_PATH=~/Tools/JUCE/modules
cmake ..")
else()
set(USER_JUCE_PATH $ENV{JUCE_PATH})
endif()
else()
set(USER_JUCE_PATH ${JUCE_PATH})
endif()
# ===========================
# | Directory configuration |
# ===========================
set(USER_SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/Source)
set(USER_LIBRARIES_DIR ${CMAKE_CURRENT_LIST_DIR}/Libraries)
set(USER_RESOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/Resources)
set(USER_JUCELIBRARYCODE_DIR ${CMAKE_CURRENT_LIST_DIR}/JuceLibraryCode)
# ===============================
# | Build and include libraries |
# ===============================
add_subdirectory(${USER_LIBRARIES_DIR})
foreach(include_item ${EXTRA_INCLUDES})
include_directories(${USER_LIBRARIES_DIR}/${include_item})
endforeach()
# ==================================
# | Include JUCE related libraries |
# ==================================
include_directories(${USER_JUCE_PATH} ${USER_JUCELIBRARYCODE_DIR})
# ==================
# | Set build type |
# ==================
if(NOT "${CMAKE_BUILD_TYPE}" STREQUAL "")
string(TOUPPER ${CMAKE_BUILD_TYPE} CMAKE_BUILD_TYPE_UPPER)
if(${CMAKE_BUILD_TYPE_UPPER} STREQUAL "DEBUG")
add_compile_definitions(DEBUG)
add_compile_definitions(_DEBUG)
add_compile_definitions(JUCE_DEBUG)
else()
add_compile_definitions(NDEBUG)
endif()
endif()
# =========================================
# | Warn about using these configurations |
# =========================================
if(DEFINED JUCE_TITLE_BAR)
message(STATUS "Using JUCE's own titlebar implementation.")
message(WARNING "Please be aware that this disables native window-manager functionalities, like snap, maximizing on dragging the window to the edge, etc.!")
set(USER_APPCONFIG_HEADER "#define JUCE_TITLE_BAR\n")
endif()
if(DEFINED JUCE_TITLE_BAR)
message(STATUS "Using a light colorscheme")
message(WARNING "Please be aware that this colorscheme is not fully implemented at the moment and might look incomplete!")
set(USER_APPCONFIG_HEADER "#define USE_LIGHT_COLORSCHEME\n")
endif()
# ============================
# | Parse UserAppConfig.h.in |
# ============================
configure_file (
"${USER_JUCELIBRARYCODE_DIR}/CMake.h.in"
"${USER_JUCELIBRARYCODE_DIR}/CMake.h"
)
add_compile_definitions(CMAKE_H_PARSED)
# =========================
# | Define Resource files |
# =========================
set(RESOURCES "Resources/Logo.png")
# ==============================================
# | Define JUCE specific Source & Header files |
# ==============================================
set(JUCE_SOURCES
"${USER_JUCELIBRARYCODE_DIR}/BinaryData.cpp"
"${USER_JUCELIBRARYCODE_DIR}/include_juce_core.cpp"
"${USER_JUCELIBRARYCODE_DIR}/include_juce_data_structures.cpp"
"${USER_JUCELIBRARYCODE_DIR}/include_juce_events.cpp"
"${USER_JUCELIBRARYCODE_DIR}/include_juce_graphics.cpp"
"${USER_JUCELIBRARYCODE_DIR}/include_juce_gui_basics.cpp"
"${USER_JUCELIBRARYCODE_DIR}/include_juce_gui_extra.cpp"
"${USER_JUCELIBRARYCODE_DIR}/include_juce_opengl.cpp"
)
set(JUCE_HEADERS
"${USER_JUCELIBRARYCODE_DIR}/AppConfig.h"
"${USER_JUCELIBRARYCODE_DIR}/BinaryData.h"
"${USER_JUCELIBRARYCODE_DIR}/CMake.h"
"${USER_JUCELIBRARYCODE_DIR}/JuceHeader.h"
)
# ================================
# | Define Source & Header files |
# ================================
set(SOURCES
"${USER_SOURCE_DIR}/AddComponent.cpp"
"${USER_SOURCE_DIR}/AddEntryComponent.cpp"
"${USER_SOURCE_DIR}/AddUserComponent.cpp"
"${USER_SOURCE_DIR}/CustomTableListBox.cpp"
"${USER_SOURCE_DIR}/ExpandArea.cpp"
"${USER_SOURCE_DIR}/ExpandEntryArea.cpp"
"${USER_SOURCE_DIR}/ExpandUserArea.cpp"
"${USER_SOURCE_DIR}/Main.cpp"
"${USER_SOURCE_DIR}/PostFunctions.cpp"
)
set(HEADERS
"${USER_SOURCE_DIR}/AddComponent.h"
"${USER_SOURCE_DIR}/AddEntryComponent.h"
"${USER_SOURCE_DIR}/AdditionalFunctions.h"
"${USER_SOURCE_DIR}/AddUserComponent.h"
"${USER_SOURCE_DIR}/ConstFields.h"
"${USER_SOURCE_DIR}/CustomTableListBox.h"
"${USER_SOURCE_DIR}/DustLookAndFeel.h"
"${USER_SOURCE_DIR}/ExpandArea.h"
"${USER_SOURCE_DIR}/ExpandEntryArea.h"
"${USER_SOURCE_DIR}/ExpandUserArea.h"
"${USER_SOURCE_DIR}/Global.h"
"${USER_SOURCE_DIR}/PostFunctions.h"
"${USER_SOURCE_DIR}/targetver.h"
"${USER_SOURCE_DIR}/ToggleAreaButton.h"
"${USER_SOURCE_DIR}/UserInteraction.h"
)
# ========================
# | Define source groups |
# ========================
source_group("ComminuCare_eV_Manager/Resources" FILES ${RESOURCES})
source_group("ComminuCare_eV_Manager/Source" FILES ${SOURCES} ${HEADERS})
# =====================================
# | Add executable and link libraries |
# =====================================
add_executable(${PROJECT_NAME} ${JUCE_SOURCES} ${SOURCES})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment