Skip to content

Commit

Permalink
Update cmake
Browse files Browse the repository at this point in the history
Auto detect filesystem
  • Loading branch information
TianZerL committed Oct 1, 2020
1 parent f9728fe commit 38a0ea4
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Build
build
install
ThirdParty
DetectionSample
settings.ini
logo.rc
*.aps
14 changes: 13 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,28 @@ if(WIN32)
set(CMAKE_INSTALL_PREFIX ${TOP_DIR}/install)
endif(WIN32)

include(${TOP_DIR}/cmake/Detection.cmake)

option(Build_GUI "Build GUI or not" OFF)
option(Build_CLI "Build CLI or not" ON)
option(Build_VapourSynth_plugin "Build Anime4KCPP for VapourSynth plugin or not" OFF)
option(Build_AviSynthPlus_plugin "Build Anime4KCPP for AviSynthPlus plugin or not" OFF)
option(Build_C_wrapper "Build C wrapper of Anime4KCPP or not" OFF)
option(Build_C_wrapper_with_core "Build C wrapper and core in one file" OFF)
option(Built_in_kernel "Built-in kernel or not" ON)
option(Use_Boost_filesystem "Use filesystem lib from boost instead of STL" OFF)
option(Use_TBB "Use TBB for parallel processing" OFF)

if(HAS_FILESYSTEM)
option(Use_Boost_filesystem "Use filesystem lib from boost instead of STL" OFF)
else()
message (
STATUS "Failed to complie has_filesystem.cpp, will use boost::filesystem instead of std::filesyste\n"
"Error message:\n"
${HAS_FILESYSTEM_MSG}
)
option(Use_Boost_filesystem "Use filesystem lib from boost instead of STL" ON)
endif()

if(WIN32)
set(OpenCL_Provider "Intel" CACHE STRING "one of Intel;Nvidia;AMD;Auto")
else()
Expand Down
35 changes: 35 additions & 0 deletions cmake/Detection.cmake
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()

0 comments on commit 38a0ea4

Please sign in to comment.