Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Add support for FreeBSD. #32

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ if(CMAKE_SYSTEM_NAME STREQUAL Windows)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR})
add_compile_definitions(SOKOL_GLCORE33)
add_compile_definitions(GOLF_PLATFORM_WINDOWS)
elseif(CMAKE_SYSTEM_NAME STREQUAL Linux OR CMAKE_SYSTEM_NAME STREQUAL Darwin)
elseif(CMAKE_SYSTEM_NAME STREQUAL Linux OR CMAKE_SYSTEM_NAME STREQUAL Darwin OR CMAKE_SYSTEM_NAME STREQUAL FreeBSD)
add_compile_definitions(SOKOL_GLCORE33)
add_compile_definitions(GOLF_PLATFORM_LINUX)
elseif(CMAKE_SYSTEM_NAME STREQUAL Android)
Expand Down Expand Up @@ -52,6 +52,11 @@ elseif(CMAKE_SYSTEM_NAME STREQUAL Linux)
add_compile_options(-g)
endif()

if(CMAKE_SYSTEM_NAME STREQUAL FreeBSD)
include_directories("/usr/local/include")
link_directories("/usr/local/lib")
endif()

add_subdirectory(src/3rd_party/cimgui)
add_subdirectory(src/3rd_party/fast_obj)
add_subdirectory(src/3rd_party/glad)
Expand All @@ -66,6 +71,6 @@ add_subdirectory(src/3rd_party/xatlas)
add_subdirectory(src/common)
add_subdirectory(src/golf)

if(CMAKE_SYSTEM_NAME STREQUAL Windows OR CMAKE_SYSTEM_NAME STREQUAL Linux)
if(CMAKE_SYSTEM_NAME STREQUAL Windows OR CMAKE_SYSTEM_NAME STREQUAL Linux OR CMAKE_SYSTEM_NAME STREQUAL FreeBSD)
add_subdirectory(src/editor)
endif()
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ A cross-platform minigolf game written in C.

- To start the game run `out/osx/golf`

## FreeBSD
- To compile run `./build/build-freebsd.sh`

- To start the game run `out/freebsd/golf`

## 3rd Party Libraries
- [cembed](https://github.com/rxi/cembed)
- [cimgui](https://github.com/cimgui/cimgui)
Expand Down
7 changes: 7 additions & 0 deletions build/build-freebsd.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
mkdir -p out
mkdir -p out/freebsd
mkdir -p out/temp
cd out/freebsd
cmake ../..
cmake --build .
cd ../..
16 changes: 16 additions & 0 deletions src/3rd_party/glfw/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,20 @@ elseif(CMAKE_SYSTEM_NAME STREQUAL Linux)
src/xkb_unicode.c
src/glx_context.c)
target_compile_definitions(glfw PRIVATE _GLFW_X11)
elseif(CMAKE_SYSTEM_NAME STREQUAL FreeBSD)
target_sources(glfw PRIVATE
src/posix_time.h
src/posix_thread.h
src/posix_module.c
src/posix_time.c
src/posix_thread.c
src/x11_platform.h
src/xkb_unicode.h
src/x11_init.c
src/x11_monitor.c
src/x11_window.c
src/xkb_unicode.c
src/glx_context.c)
target_compile_definitions(glfw PRIVATE _GLFW_X11)

endif()
2 changes: 1 addition & 1 deletion src/editor/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ set(EDITOR_LIBRARIES
stb
xatlas)

if(CMAKE_SYSTEM_NAME STREQUAL Linux)
if(CMAKE_SYSTEM_NAME STREQUAL Linux OR CMAKE_SYSTEM_NAME STREQUAL FreeBSD)
set(EDITOR_LIBRARIES
${EDITOR_LIBRARIES}
-lX11
Expand Down
2 changes: 1 addition & 1 deletion src/golf/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ else()
main.c
ui.c
"${IOS_ICON}")
if(CMAKE_SYSTEM_NAME STREQUAL Linux)
if(CMAKE_SYSTEM_NAME STREQUAL Linux OR CMAKE_SYSTEM_NAME STREQUAL FreeBSD)
set(GOLF_LIBRARIES
${GOLF_LIBRARIES}
-lX11
Expand Down