From 2b2be69a5934dfd6c2505a5a99ab59473e6b9a39 Mon Sep 17 00:00:00 2001 From: Precise <3824793+Mr-Precise@users.noreply.github.com> Date: Sat, 18 Dec 2021 09:50:11 +0100 Subject: [PATCH] Add CMake build support --- .gitignore | 3 +++ CMakeLists.txt | 27 +++++++++++++++++++++++++++ README.md | 23 +++++++++++++++++++++++ MAKE_LINUX => src/MAKE_LINUX | 0 MAKE_MACOS => src/MAKE_MACOS | 0 Makefile => src/Makefile | 0 ps.c => src/ps.c | 0 7 files changed, 53 insertions(+) create mode 100644 .gitignore create mode 100644 CMakeLists.txt rename MAKE_LINUX => src/MAKE_LINUX (100%) rename MAKE_MACOS => src/MAKE_MACOS (100%) rename Makefile => src/Makefile (100%) rename ps.c => src/ps.c (100%) diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..6cbca87 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +.vscode/ +build/ +bin/ diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..a5a7733 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,27 @@ +cmake_minimum_required(VERSION 3.0.2) +project(PS C) + +find_package(SDL2 REQUIRED) + +# set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mwindows -s") +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -s") + +file(GLOB_RECURSE ${PROJECT_NAME}_SRC + ${CMAKE_CURRENT_SOURCE_DIR}/src/**.c +) + +include_directories(${SDL2_INCLUDE_DIRS}) + +add_executable(${PROJECT_NAME} ${${PROJECT_NAME}_SRC}) +target_link_libraries(${PROJECT_NAME} ${SDL2_LIBRARIES}) +if(WIN32) + target_link_libraries(${PROJECT_NAME} imm32 winmm version setupapi hid) +endif(WIN32) +if(MINGW) + target_link_libraries(${PROJECT_NAME} imm32 winmm version setupapi hid samplerate) +endif(MINGW) + +target_link_libraries(${PROJECT_NAME} ${SDL2_LIBRARIES} m) + +install(TARGETS ${PROJECT_NAME} + DESTINATION ${CMAKE_INSTALL_BINDIR}) diff --git a/README.md b/README.md index 5b8b480..e34ee9c 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,29 @@ All sounds and notes were entered manually without using any music programs. One single source file contains synth code, patterns and player. No third party libraries are used except SDL2 to output the audio stream. +--- +Added support cmake build system. + +Linux build: +``` +mkdir build && cd build +cmake -G "Unix Makefiles" .. +make +``` +MinGW32 or MXE CrossCompiling: +``` +mkdir build && cd build +cmake -G "Unix Makefiles" .. -DCMAKE_TOOLCHAIN_FILE=Your-CrossCompiling-Toolchain-file.cmake +make +``` + +Windows build: +``` +cmake -G "Visual Studio 16 2019" -A x64 -B "build" +``` +Open .sln in Visual Studio... etc... + +--- Usage: * just play the song: `./ps` * export to WAV: `./ps -o filename.wav` diff --git a/MAKE_LINUX b/src/MAKE_LINUX similarity index 100% rename from MAKE_LINUX rename to src/MAKE_LINUX diff --git a/MAKE_MACOS b/src/MAKE_MACOS similarity index 100% rename from MAKE_MACOS rename to src/MAKE_MACOS diff --git a/Makefile b/src/Makefile similarity index 100% rename from Makefile rename to src/Makefile diff --git a/ps.c b/src/ps.c similarity index 100% rename from ps.c rename to src/ps.c