Skip to content

Commit c302f10

Browse files
committed
Add FreeBSD support
For now, there's only single OS-dependent bit of code, it it should be handled on FreeBSD just like on Linux. While here, change macro testing from #if XXX to #if defined(XXX), this is clener and not prone to "undefined macro" errors
1 parent b7ac33c commit c302f10

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

CMakeLists.txt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,11 @@ option(ENABLE_PROFILING "Enable detailed profiling metrics")
2727
#
2828

2929
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
30-
add_definitions(-DRW_LINUX=1)
30+
add_definitions(-DRW_LINUX)
3131
elseif (CMAKE_SYSTEM_NAME STREQUAL "Darwin")
32-
add_definitions(-DRW_OSX=1)
32+
add_definitions(-DRW_OSX)
33+
elseif(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD")
34+
add_definitions(-DRW_FREEBSD)
3335
else ()
3436
message(FATAL_ERROR "Unknown platform \"${CMAKE_SYSTEM_NAME}\". please update CMakeLists.txt.")
3537
endif ()

rwgame/GameConfig.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ bool GameConfig::isValid()
4343

4444
std::string GameConfig::getDefaultConfigPath()
4545
{
46-
#if RW_LINUX
46+
#if defined(RW_LINUX) || defined(RW_FREEBSD)
4747
char* config_home = getenv("XDG_CONFIG_HOME");
4848
if (config_home != nullptr) {
4949
return std::string(config_home) + "/" + kConfigDirectoryName;
@@ -53,7 +53,7 @@ std::string GameConfig::getDefaultConfigPath()
5353
return std::string(home) + "/.config/" + kConfigDirectoryName;
5454
}
5555

56-
#elif RW_OSX
56+
#elif defined(RW_OSX)
5757
char* home = getenv("HOME");
5858
if (home)
5959
return std::string(home) + "/Library/Preferences/" + kConfigDirectoryName;

0 commit comments

Comments
 (0)