-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Use targets instead of environment variables where possible - Use XRootD's find_package over local one - Remove compatibility macros with very old CMake - Add improved std::filesystem detection - Always run with `-Werror` in Debug mode
- Loading branch information
Showing
5 changed files
with
103 additions
and
117 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
|
||
# Ideas come from | ||
# | ||
# https://gitlab.kitware.com/cmake/cmake/-/issues/17834 | ||
# | ||
# Basically, upstream CMake claims the fact that a separate library is | ||
# needed for std::filesystem support is a short-lived fact (of all the | ||
# platforms we use, only RHEL 8 uses a compiler where this is needed), | ||
# hence they don't want a standardized way to detect std::filesystem | ||
|
||
include(CheckSourceCompiles) | ||
|
||
set( CMAKE_REQUIRED_INCLUDES "${XRootD_INCLUDE_DIR}" ) | ||
set( SAMPLE_FILESYSTEM "#include <cstdlib> | ||
#include <filesystem> | ||
int main() { | ||
auto cwd = std::filesystem::current_path(); | ||
return cwd.empty(); | ||
}") | ||
|
||
|
||
CHECK_SOURCE_COMPILES( CXX "${SAMPLE_FILESYSTEM}" CXX_FILESYSTEM_NO_LINK_NEEDED ) | ||
|
||
set( _found FALSE ) | ||
if( CXX_FILESYSTEM_NO_LINK_NEEDED ) | ||
set( _found TRUE ) | ||
else() | ||
# Add the libstdc++ flag | ||
set( CMAKE_REQUIRED_LIBRARIES "-lstdc++fs" ) | ||
CHECK_SOURCE_COMPILES( CXX "${SAMPLE_FILESYSTEM}" CXX_FILESYSTEM_STDCPPFS_NEEDED ) | ||
set( _found TRUE ) | ||
endif() | ||
|
||
add_library( std::filesystem INTERFACE IMPORTED ) | ||
#set_property( TARGET std::filesystem APPEND PROPERTY INTERFACE_COMPILE_FEATURES cxx_std_17 ) | ||
|
||
if( CXX_FILESYSTEM_STDCPPFS_NEEDED ) | ||
set_property( TARGET std::filesystem APPEND PROPERTY INTERFACE_LINK_LIBRARIES -lstdc++fs ) | ||
endif() | ||
|
||
set( Filesystem_FOUND ${_found} CACHE BOOL "TRUE if we can run a program using std::filesystem" FORCE ) | ||
if( Filesystem_FIND_REQUIRED AND NOT Filesystem_FOUND ) | ||
message( FATAL_ERROR "Cannot run simple program using std::filesystem" ) | ||
endif() |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters