Skip to content

Commit

Permalink
cmake: detect realpath
Browse files Browse the repository at this point in the history
Change the realpath definition to have a CLAR_ prefix -
`CLAR_HAS_REALPATH` - and check in the CMake run for it.
  • Loading branch information
ethomson committed Jan 23, 2025
1 parent fac823c commit 13931e5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
7 changes: 7 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
include(CheckFunctionExists)

cmake_minimum_required(VERSION 3.16..3.29)

project(clar LANGUAGES C)

option(BUILD_EXAMPLE "Build the example." ON)

check_function_exists(realpath CLAR_HAS_REALPATH)
if(CLAR_HAS_REALPATH)
add_compile_definitions(-DCLAR_HAS_REALPATH)
endif()

add_library(clar INTERFACE)
target_sources(clar INTERFACE
clar.c
Expand Down
2 changes: 1 addition & 1 deletion clar/sandbox.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ static int canonicalize_tmp_path(char *buffer)
*p = '/';

return 0;
#elif defined(__APPLE__) || defined(HAS_REALPATH)
#elif defined(CLAR_HAS_REALPATH)
char tmp[CLAR_MAX_PATH];

if (realpath(buffer, tmp) == NULL)
Expand Down

0 comments on commit 13931e5

Please sign in to comment.