forked from milkytracker/MilkyTracker
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This commit adds a complete CMake-based build system targetting Windows, Mac OS X and UNIX-likes. Whenever a non-critical library cannot be found, the dependant features are simply disabled and MilkyTracker can be built without them. System-provided libraries are used for the build instead of the bundled versions, except on Windows, which still requires the library sources. On Windows and OS X, all libraries not provided by the operating system are linked statically. This includes the Visual C/C++ runtime on Windows (alleviating the need to install a runtime).
- Loading branch information
Showing
16 changed files
with
2,249 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,158 @@ | ||
# | ||
# CMakeLists.txt | ||
# | ||
# Copyright 2016 Dale Whinham | ||
# | ||
# This file is part of MilkyTracker. | ||
# | ||
# MilkyTracker is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License as published by | ||
# the Free Software Foundation, either version 3 of the License, or | ||
# (at your option) any later version. | ||
# | ||
# MilkyTracker is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License | ||
# along with MilkyTracker. If not, see <http://www.gnu.org/licenses/>. | ||
# | ||
|
||
cmake_minimum_required(VERSION 2.6) | ||
project(MilkyTracker) | ||
|
||
# Lowercase project name for binaries and packaging | ||
string(TOLOWER ${PROJECT_NAME} PROJECT_NAME_LOWER) | ||
|
||
# Additional CMake modules | ||
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PROJECT_SOURCE_DIR}/cmake) | ||
|
||
# Version number in format X.YY.ZZ | ||
set(VER_X 0) | ||
set(VER_YY 90) | ||
set(VER_ZZ 87) | ||
set(VER_FULL "${VER_X}.${VER_YY}.${VER_ZZ}") | ||
|
||
# Generate version header from the above | ||
configure_file( | ||
${PROJECT_SOURCE_DIR}/src/tracker/version.h.in | ||
${PROJECT_BINARY_DIR}/src/tracker/version.h | ||
) | ||
|
||
if(APPLE) | ||
# Set variables for generating the Info.plist file | ||
set(MACOSX_BUNDLE_BUNDLE_VERSION "${VER_FULL}") | ||
set(MACOSX_BUNDLE_EXECUTABLE ${PROJECT_NAME}) | ||
set(MACOSX_BUNDLE_GUI_IDENTIFIER "com.Titan.MilkyTracker") | ||
set(MACOSX_BUNDLE_NSMAIN_NIB_FILE "Application") | ||
set(MACOSX_BUNDLE_ICON_FILE "carton") | ||
set(MACOSX_BUNDLE_NAME ${PROJECT_NAME}) | ||
set(MACOSX_BUNDLE_SHORT_VERSION_STRING "${VER_FULL}") | ||
|
||
# Carbon only required for HIToolbox/Events.h (virtual keycodes) | ||
find_library(CARBON_LIBRARY Carbon) | ||
find_library(COCOA_LIBRARY Cocoa) | ||
find_library(CORE_AUDIO_LIBRARY CoreAudio) | ||
find_library(CORE_FOUNDATION_LIBRARY CoreFoundation) | ||
find_library(CORE_MIDI_LIBRARY CoreMIDI) | ||
find_library(CORE_VIDEO_LIBRARY CoreVideo) | ||
find_library(OPENGL_LIBRARY OpenGL) | ||
|
||
# OS X MIDI support requires no external libraries | ||
message(STATUS "Enabled MIDI support (Core MIDI)") | ||
add_subdirectory(src/midi) | ||
elseif(WIN32) | ||
# Visual C++ Compiler options | ||
if(MSVC) | ||
# Warn if platform toolset may not be targetting Windows XP upwards | ||
if(NOT ${CMAKE_VS_PLATFORM_TOOLSET} MATCHES "xp") | ||
message("WARNING:") | ||
message("Your currently-selected platform toolset may generate") | ||
message("executables which are incompatible with Windows XP.") | ||
message("Please set your toolset to be one of v110_xp, v120_xp or") | ||
message("v140_xp for VS2012, VS2013, and VS2015 respectively.") | ||
message("You can do so with the '-T' argument to CMake, or by") | ||
message("entering it in the CMake GUI.") | ||
endif() | ||
|
||
# Suppress secure string function warnings | ||
add_definitions(-D_CRT_SECURE_NO_WARNINGS) | ||
|
||
# Enable parallel compilation | ||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /MP") | ||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP") | ||
|
||
# Enable static linkage of the Microsoft Visual C/C++ Runtime | ||
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /MTd") | ||
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} /MT") | ||
set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} /MTd") | ||
set(CMAKE_C_FLAGS_MINSIZEREL "${CMAKE_C_FLAGS_MINSIZEREL} /MT") | ||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MTd") | ||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MT") | ||
set( | ||
CMAKE_CXX_FLAGS_RELWITHDEBINFO | ||
"${CMAKE_CXX_FLAGS_RELWITHDEBINFO} /MTd" | ||
) | ||
set(CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL} /MT") | ||
endif() | ||
|
||
# Prevent Windows.h from clashing with the Standard Template Library so we | ||
# can use std::min/std::max (see https://support.microsoft.com/kb/143208) | ||
add_definitions(-DNOMINMAX) | ||
|
||
# Windows MIDI support requires no external libraries | ||
message(STATUS "Enabled MIDI support (WinMM)") | ||
add_subdirectory(src/midi) | ||
else() | ||
# Workaround for SDL bug #3295, which we might hit if the distro's SDL2 | ||
# package includes the sdl2-config.cmake file | ||
# https://bugzilla.libsdl.org/show_bug.cgi?id=3295 | ||
cmake_policy(SET CMP0004 OLD) | ||
|
||
find_package(SDL2 REQUIRED) | ||
endif() | ||
|
||
# Prefer static linkage under OS X for libraries located with find_package() | ||
if(APPLE) | ||
set(SUFFIXES_ORIG ${CMAKE_FIND_LIBRARY_SUFFIXES}) | ||
set(CMAKE_FIND_LIBRARY_SUFFIXES .a ${CMAKE_FIND_LIBRARY_SUFFIXES}) | ||
endif() | ||
|
||
# Under Windows we use Git Submodules to locate the decompression libraries | ||
if(UNIX) | ||
if(${CMAKE_SYSTEM_NAME} MATCHES "Linux") | ||
find_package(ALSA) | ||
|
||
# Linux MIDI support requires ALSA and RtMidi | ||
if(ALSA_FOUND) | ||
find_package(RTMIDI 2.1.0) | ||
if(RTMIDI_FOUND) | ||
message(STATUS "Enabled MIDI support (ALSA/RtMidi)") | ||
add_subdirectory(src/midi) | ||
else() | ||
message("MIDI support disabled (RtMidi unavailable)") | ||
endif() | ||
else() | ||
message("MIDI support disabled (ALSA unavailable)") | ||
endif() | ||
endif() | ||
|
||
if(NOT APPLE) | ||
find_package(JACK) | ||
endif() | ||
find_package(LHASA) | ||
find_package(ZLIB) | ||
find_package(ZZIPLIB) | ||
endif() | ||
|
||
# Restore library suffixes | ||
if(APPLE) | ||
set(CMAKE_FIND_LIBRARY_SUFFIXES ${SUFFIXES_ORIG}) | ||
endif() | ||
|
||
add_subdirectory(src/compression) | ||
add_subdirectory(src/fx) | ||
add_subdirectory(src/milkyplay) | ||
add_subdirectory(src/ppui) | ||
add_subdirectory(src/tracker) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
# | ||
# cmake/FindJACK.cmake | ||
# | ||
# Copyright 2016 Dale Whinham | ||
# | ||
# This file is part of MilkyTracker. | ||
# | ||
# MilkyTracker is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License as published by | ||
# the Free Software Foundation, either version 3 of the License, or | ||
# (at your option) any later version. | ||
# | ||
# MilkyTracker is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License | ||
# along with MilkyTracker. If not, see <http://www.gnu.org/licenses/>. | ||
# | ||
|
||
# - Try to find JACK | ||
# Once done this will define | ||
# JACK_FOUND - System has JACK | ||
# JACK_INCLUDE_DIRS - The JACK include directories | ||
# JACK_LIBRARIES - The libraries needed to use JACK | ||
# JACK_DEFINITIONS - Compiler switches required for using JACK | ||
# JACK_VERSION_STRING - The version of JACK | ||
|
||
find_package(PkgConfig QUIET) | ||
pkg_check_modules(PC_JACK QUIET jack) | ||
set(JACK_DEFINITIONS ${PC_JACK_CFLAGS_OTHER}) | ||
|
||
find_path( | ||
JACK_INCLUDE_DIR jack/jack.h | ||
HINTS ${PC_JACK_INCLUDEDIR} ${PC_JACK_INCLUDE_DIRS} | ||
) | ||
|
||
find_library(JACK_LIBRARY NAMES jack | ||
HINTS ${PC_JACK_LIBDIR} ${PC_JACK_LIBRARY_DIRS} | ||
) | ||
|
||
# Get version from pkg-config if possible | ||
if(PC_JACK_VERSION) | ||
set(JACK_VERSION_STRING ${PC_JACK_VERSION}) | ||
endif() | ||
|
||
include(FindPackageHandleStandardArgs) | ||
|
||
find_package_handle_standard_args( | ||
JACK | ||
REQUIRED_VARS JACK_LIBRARY JACK_INCLUDE_DIR | ||
VERSION_VAR JACK_VERSION_STRING | ||
) | ||
|
||
mark_as_advanced(JACK_INCLUDE_DIR JACK_LIBRARY) | ||
|
||
if(JACK_FOUND) | ||
set(JACK_LIBRARIES ${JACK_LIBRARY}) | ||
set(JACK_INCLUDE_DIRS ${JACK_INCLUDE_DIR}) | ||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
# | ||
# cmake/FindLHASA.cmake | ||
# | ||
# Copyright 2016 Dale Whinham | ||
# | ||
# This file is part of MilkyTracker. | ||
# | ||
# MilkyTracker is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License as published by | ||
# the Free Software Foundation, either version 3 of the License, or | ||
# (at your option) any later version. | ||
# | ||
# MilkyTracker is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License | ||
# along with MilkyTracker. If not, see <http://www.gnu.org/licenses/>. | ||
# | ||
|
||
# - Try to find lhasa | ||
# Once done this will define | ||
# LHASA_FOUND - System has zziplib | ||
# LHASA_INCLUDE_DIRS - The zziplib include directories | ||
# LHASA_LIBRARIES - The libraries needed to use zziplib | ||
# LHASA_DEFINITIONS - Compiler switches required for using zziplib | ||
# LHASA_VERSION_STRING - The version of zziplib | ||
|
||
find_package(PkgConfig QUIET) | ||
pkg_check_modules(PC_LHASA QUIET liblhasa) | ||
set(LHASA_DEFINITIONS ${PC_LHASA_CFLAGS_OTHER}) | ||
|
||
find_path( | ||
LHASA_INCLUDE_DIR lhasa.h | ||
HINTS ${PC_LHASA_INCLUDEDIR} ${PC_LHASA_INCLUDE_DIRS} | ||
) | ||
|
||
find_library( | ||
LHASA_LIBRARY NAMES lhasa | ||
HINTS ${PC_LHASA_LIBDIR} ${PC_LHASA_LIBRARY_DIRS} | ||
) | ||
|
||
# Get version from pkg-config if possible | ||
set(LHASA_VERSION_STRING ${PC_LHASA_VERSION}) | ||
|
||
include(FindPackageHandleStandardArgs) | ||
|
||
find_package_handle_standard_args(LHASA | ||
REQUIRED_VARS LHASA_LIBRARY LHASA_INCLUDE_DIR | ||
VERSION_VAR LHASA_VERSION_STRING) | ||
|
||
mark_as_advanced(LHASA_INCLUDE_DIR LHASA_LIBRARY) | ||
|
||
if(LHASA_FOUND) | ||
set(LHASA_LIBRARIES ${LHASA_LIBRARY}) | ||
set(LHASA_INCLUDE_DIRS ${LHASA_INCLUDE_DIR}) | ||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
# | ||
# cmake/FindRTMIDI.cmake | ||
# | ||
# Copyright 2016 Dale Whinham | ||
# | ||
# This file is part of MilkyTracker. | ||
# | ||
# MilkyTracker is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License as published by | ||
# the Free Software Foundation, either version 3 of the License, or | ||
# (at your option) any later version. | ||
# | ||
# MilkyTracker is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License | ||
# along with MilkyTracker. If not, see <http://www.gnu.org/licenses/>. | ||
# | ||
|
||
# - Try to find RtMidi | ||
# Once done this will define | ||
# RTMIDI_FOUND - System has RtMidi | ||
# RTMIDI_INCLUDE_DIRS - The RtMidi include directories | ||
# RTMIDI_LIBRARIES - The libraries needed to use RtMidi | ||
# RTMIDI_DEFINITIONS - Compiler switches required for using RtMidi | ||
# RTMIDI_VERSION_STRING - The version of RtMidin | ||
|
||
find_package(PkgConfig QUIET) | ||
pkg_check_modules(PC_RTMIDI QUIET rtmidi) | ||
set(RTMIDI_DEFINITIONS ${PC_RTMIDI_CFLAGS_OTHER}) | ||
|
||
find_path( | ||
RTMIDI_INCLUDE_DIR RtMidi.h | ||
HINTS ${PC_RTMIDI_INCLUDEDIR} ${PC_RTMIDI_INCLUDE_DIRS} | ||
PATH_SUFFIXES rtmidi | ||
) | ||
|
||
find_library( | ||
RTMIDI_LIBRARY NAMES rtmidi | ||
HINTS ${PC_RTMIDI_LIBDIR} ${PC_RTMIDI_LIBRARY_DIRS} | ||
) | ||
|
||
# Get version from pkg-config if possible, else scrape it from the header | ||
if(PC_RTMIDI_VERSION) | ||
set(RTMIDI_VERSION_STRING ${PC_RTMIDI_VERSION}) | ||
elseif(RTMIDI_INCLUDE_DIR AND EXISTS "${RTMIDI_INCLUDE_DIR}/RtMidi.h") | ||
file( | ||
STRINGS "${RTMIDI_INCLUDE_DIR}/RtMidi.h" RTMIDI_VERSION_LINE | ||
REGEX "^// RtMidi: Version .*$" | ||
) | ||
string( | ||
REGEX REPLACE "^.*Version (.*)$" "\\1" RTMIDI_VERSION_STRING | ||
${RTMIDI_VERSION_LINE} | ||
) | ||
unset(RTMIDI_VERSION_LINE) | ||
endif() | ||
|
||
include(FindPackageHandleStandardArgs) | ||
|
||
find_package_handle_standard_args( | ||
RTMIDI | ||
REQUIRED_VARS RTMIDI_LIBRARY RTMIDI_INCLUDE_DIR | ||
VERSION_VAR RTMIDI_VERSION_STRING | ||
) | ||
|
||
mark_as_advanced(RTMIDI_INCLUDE_DIR RTMIDI_LIBRARY) | ||
|
||
if(RTMIDI_FOUND) | ||
set(RTMIDI_LIBRARIES ${RTMIDI_LIBRARY}) | ||
set(RTMIDI_INCLUDE_DIRS ${RTMIDI_INCLUDE_DIR}) | ||
endif() |
Oops, something went wrong.