60 lines
2.3 KiB
CMake
Executable file
60 lines
2.3 KiB
CMake
Executable file
#Variables
|
|
#-----------------------------------------------------------------------------------------
|
|
set(PROJ_NAME PianoLibrary)
|
|
set(MAJOR_VER 0)
|
|
set(MINOR_VER 1)
|
|
#-----------------------------------------------------------------------------------------
|
|
|
|
#Setup
|
|
#-----------------------------------------------------------------------------------------
|
|
set(CMAKE_CXX_COMPILER "clang++")
|
|
set(CMAKE_C_COMPILER "clang")
|
|
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
|
cmake_minimum_required(VERSION 3.18)
|
|
project(${PROJ_NAME} LANGUAGES C CXX)
|
|
set(CMAKE_CXX_STANDARD 20)
|
|
file(STRINGS "./other/build.nr" BUILD_NUMBER)
|
|
#-----------------------------------------------------------------------------------------
|
|
|
|
message(STATUS "Building ${PROJ_NAME} ${MAJOR_VER}.${MINOR_VER}.${BUILD_NUMBER}")
|
|
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
|
|
message(STATUS "Debug Configuration")
|
|
elseif(CMAKE_BUILD_TYPE STREQUAL "Release")
|
|
message(STATUS "Release Configuration")
|
|
endif()
|
|
|
|
#Sources
|
|
#-----------------------------------------------------------------------------------------
|
|
list(APPEND INCLUDE_DIRS
|
|
${CMAKE_CURRENT_LIST_DIR}/src
|
|
)
|
|
list(APPEND SOURCE_FILES
|
|
${CMAKE_CURRENT_LIST_DIR}/src/main.cpp
|
|
)
|
|
#-----------------------------------------------------------------------------------------
|
|
|
|
#Targets
|
|
#-----------------------------------------------------------------------------------------
|
|
set(APP_TARGET pianolib)
|
|
add_executable(${APP_TARGET} ${SOURCE_FILES})
|
|
target_include_directories(${APP_TARGET} PUBLIC ${INCLUDE_DIRS})
|
|
|
|
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
|
|
add_compile_options(-O3 -MMD -MP -Wall -ggdb -fsanitize=address)
|
|
target_compile_definitions(${APP_TARGET} PUBLIC PIANOLIB_DEBUG_BUILD)
|
|
elseif(CMAKE_BUILD_TYPE STREQUAL "Release")
|
|
add_compile_options(-MMD -MP -Wall)
|
|
target_compile_definitions(${APP_TARGET} PUBLIC PIANOLIB_RELEASE_BUILD)
|
|
endif()
|
|
#-----------------------------------------------------------------------------------------
|
|
|
|
#Linking
|
|
#-----------------------------------------------------------------------------------------
|
|
target_link_libraries(${APP_TARGET} PUBLIC ostd ogfx)
|
|
|
|
if (APPLE)
|
|
cmake_policy(SET CMP0167 OLD)
|
|
elseif (UNIX)
|
|
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-rpath,'$ORIGIN',-rpath,/usr/lib,-rpath,/usr/local/lib")
|
|
endif ()
|
|
#-----------------------------------------------------------------------------------------
|