Skip to content

Commit dfc6083

Browse files
authored
Introduce better CMake OS variables (#1628)
Signed-off-by: Juan Cruz Viotti <jv@jviotti.com>
1 parent d0fae25 commit dfc6083

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

cmake/Findyaml.cmake

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ if(NOT Yaml_FOUND)
2121
target_compile_options(yaml PRIVATE -Wno-int-to-pointer-cast)
2222
endif()
2323

24-
if(LINUX)
24+
if(SOURCEMETA_OS_LINUX)
25+
message(STATUS "Compiling libyaml with _GNU_SOURCE")
2526
# See https://github.com/3DSGuy/Project_CTR/issues/122
2627
target_compile_definitions(yaml PRIVATE _GNU_SOURCE)
2728
endif()

cmake/common/variables.cmake

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,14 @@ elseif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
1010
elseif(MSVC)
1111
set(SOURCEMETA_COMPILER_MSVC ON)
1212
endif()
13+
14+
if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
15+
set(SOURCEMETA_OS_MACOS ON)
16+
# It seems that in some cases, `LINUX` is not set on GNU/Linux on WSL
17+
elseif(LINUX OR CMAKE_SYSTEM_NAME STREQUAL "Linux")
18+
set(SOURCEMETA_OS_LINUX ON)
19+
elseif(WIN32)
20+
set(SOURCEMETA_OS_WINDOWS ON)
21+
elseif(${CMAKE_SYSTEM_NAME} MATCHES ".*BSD")
22+
set(SOURCEMETA_OS_BSD ON)
23+
endif()

0 commit comments

Comments
 (0)