-
Notifications
You must be signed in to change notification settings - Fork 141
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto detect filesystem
- Loading branch information
Showing
3 changed files
with
49 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,7 @@ Build | |
build | ||
install | ||
ThirdParty | ||
DetectionSample | ||
settings.ini | ||
logo.rc | ||
*.aps |
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,35 @@ | ||
set(TMP_DIR ${PROJECT_BINARY_DIR}/tmp) | ||
set(DetectionSample_DIR ${TOP_DIR}/cmake/DetectionSample) | ||
|
||
if(NOT EXISTS ${DetectionSample_DIR}/has_filesystem.cpp) | ||
file(MAKE_DIRECTORY ${DetectionSample_DIR}) | ||
file(TOUCH ${DetectionSample_DIR}/has_filesystem.cpp) | ||
file(WRITE ${DetectionSample_DIR}/has_filesystem.cpp | ||
"#include <filesystem> | ||
int main() | ||
{ | ||
std::filesystem::path hasFS(\"./\"); | ||
return 0; | ||
} | ||
") | ||
|
||
# check std::filesystem | ||
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 9.0) | ||
try_compile(HAS_FILESYSTEM | ||
${TMP_DIR} | ||
${DetectionSample_DIR}/has_filesystem.cpp | ||
CMAKE_FLAGS -DCMAKE_CXX_STANDARD=17 -DCMAKE_CXX_STANDARD_REQUIRED=ON | ||
LINK_LIBRARIES stdc++fs | ||
OUTPUT_VARIABLE HAS_FILESYSTEM_MSG | ||
) | ||
else() | ||
try_compile(HAS_FILESYSTEM | ||
${TMP_DIR} | ||
${DetectionSample_DIR}/has_filesystem.cpp | ||
CMAKE_FLAGS -DCMAKE_CXX_STANDARD=17 -DCMAKE_CXX_STANDARD_REQUIRED=ON | ||
OUTPUT_VARIABLE HAS_FILESYSTEM_MSG | ||
) | ||
endif() | ||
|
||
endif() |