Skip to content

Commit b2ec14b

Browse files
committed
[FIX] : fix flags blending issue (under c++20) (#209)
1 parent 49baf9a commit b2ec14b

3 files changed

Lines changed: 25 additions & 7 deletions

File tree

CMakeLists.txt

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ option(USE_DIRENT_FILESYSTEM "Enable the default filesystem with dirent" ON)
1212
option(USE_STD_FILESYSTEM "Enable std::filesystem use for path and ImGuiFileDialog" OFF)
1313
option(USE_BOOST_FILESYSTEM "Enable the demo of custom filesystem here with boost" OFF)
1414

15+
option(USE_CXX_STANDARD_20 "Enable cxx standard 20 for test forward-compatibilty" OFF)
16+
1517
## some defines for debug mode (before 3rdparty.cmake)
1618
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -D_DEBUG")
1719

@@ -33,6 +35,14 @@ if (UNIX)
3335
option(USE_LEAK_SANITIZER "Enable the Leak Sanitizer" OFF)
3436
endif()
3537

38+
if(USE_CXX_STANDARD_20)
39+
if (MSVC)
40+
add_compile_options(/Zc:char8_t-) # we can keep the old const char* everywhere
41+
else()
42+
add_compile_options(-fno-char8_t) # we can keep the old const char* everywhere
43+
endif()
44+
endif()
45+
3646
include(cmake/3rdparty.cmake)
3747

3848
if (USE_BOOST_FILESYSTEM)
@@ -43,14 +53,17 @@ set(ORIGINAL_CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
4353

4454
if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
4555
add_definitions(-DMSVC)
46-
if (USE_STD_FILESYSTEM)
56+
if(USE_CXX_STANDARD_20)
57+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /std:c++20")
58+
elseif(USE_STD_FILESYSTEM)
4759
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /std:c++17")
4860
else()
4961
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /std:c++11")
5062
endif()
5163
else()
52-
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wpedantic -Wdeprecated-declarations -Wunused-parameter")
53-
if (USE_STD_FILESYSTEM)
64+
if(USE_CXX_STANDARD_20)
65+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std:c++20")
66+
elseif(USE_STD_FILESYSTEM)
5467
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17")
5568
else()
5669
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
@@ -198,6 +211,14 @@ else()
198211
message("USE C++11 and DIRENT")
199212
endif()
200213
endif()
214+
215+
if(USE_CXX_STANDARD_20)
216+
set(CMAKE_CXX_STANDARD 20)
217+
set_target_properties(${PROJECT} PROPERTIES CXX_STANDARD 20)
218+
set_target_properties(ImGuiFileDialog PROPERTIES CXX_STANDARD 20)
219+
set_target_properties(imgui PROPERTIES CXX_STANDARD 20)
220+
endif()
221+
201222
set(CMAKE_CXX_STANDARD_REQUIRED ON)
202223
set(CMAKE_CXX_EXTENSIONS OFF)
203224

ImGuiFileDialog

tests/ImGuiFileDialog/Test_FileManager.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,6 @@
55
#include <ImGuiFileDialog/ImGuiFileDialog.cpp> // for let IGFD::FileManager find the FS on destroy
66

77
#include <imgui_internal.h>
8-
9-
#include <filesystem>
10-
118
// specific
129
#ifdef WIN32
1310
#include <direct.h> // _chdir

0 commit comments

Comments
 (0)