Skip to content

Commit

Permalink
Add CMake build support
Browse files Browse the repository at this point in the history
  • Loading branch information
Mr-Precise committed Dec 18, 2021
1 parent 03fa5e1 commit 2b2be69
Show file tree
Hide file tree
Showing 7 changed files with 53 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.vscode/
build/
bin/
27 changes: 27 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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})
23 changes: 23 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 2b2be69

Please sign in to comment.