Skip to content

Commit 0789c54

Browse files
committed
Remove unnecessary feature detections, move filesystem defines to config.h.
1 parent c2f2e7a commit 0789c54

File tree

5 files changed

+18
-135
lines changed

5 files changed

+18
-135
lines changed

cmake/FilesystemSupport.cmake

+6-9
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,15 @@ unset(_old_CMAKE_CXX_STANDARD)
1818
if(NOT ENABLE_BOOST_FILESYSTEM AND STD_FILESYSTEM_EXISTS)
1919
set(CMAKE_CXX_STANDARD 17)
2020

21-
add_compile_definitions(
22-
FS_NAMESPACE=std
23-
FS_INCLUDE=<filesystem>
24-
)
21+
set(PROJECTM_FILESYSTEM_NAMESPACE std)
22+
set(PROJECTM_FILESYSTEM_INCLUDE <filesystem>)
23+
set(PROJECTM_FILESYSTEM_USE_BOOST FALSE)
2524
else()
2625
find_package(Boost REQUIRED COMPONENTS Filesystem)
2726

28-
add_compile_definitions(
29-
FS_NAMESPACE=boost
30-
FS_INCLUDE=<boost/filesystem.hpp>
31-
FS_USING_BOOST
32-
)
27+
set(PROJECTM_FILESYSTEM_NAMESPACE boost)
28+
set(PROJECTM_FILESYSTEM_INCLUDE <boost/filesystem.hpp>)
29+
set(PROJECTM_FILESYSTEM_USE_BOOST TRUE)
3330

3431
set(PROJECTM_FILESYSTEM_LIBRARY Boost::filesystem)
3532
set(ENABLE_BOOST_FILESYSTEM ON CACHE BOOL "Compiler does not support std::filesystem, reverting to boost::filesystem." FORCE)

config.h.cmake.in

+6-64
Original file line numberDiff line numberDiff line change
@@ -1,73 +1,15 @@
11
#pragma once
22

3-
/* Define to 1 if you have the `aligned_alloc' function. */
4-
#cmakedefine01 HAVE_ALIGNED_ALLOC
5-
6-
/* Define to 1 if you have the <dlfcn.h> header file. */
7-
#cmakedefine01 HAVE_DLFCN_H
8-
9-
/* Define to 1 if you have the <fts.h> header file. */
10-
#cmakedefine01 HAVE_FTS_H
11-
12-
/* Defined if a valid OpenGL implementation is found. */
13-
#cmakedefine01 HAVE_GL
14-
15-
/* Define to 1 if you have the <GLES/gl.h> header file. */
16-
#cmakedefine01 HAVE_GLES_GL_H
17-
18-
/* Define to 1 if you have the <GL/gl.h> header file. */
19-
#cmakedefine01 HAVE_GL_GL_H
20-
21-
/* Define to 1 if you have the <inttypes.h> header file. */
22-
#cmakedefine01 HAVE_INTTYPES_H
23-
24-
/* Define HAVE_LLVM */
25-
#cmakedefine01 HAVE_LLVM
26-
27-
/* Define to 1 if you have the <memory.h> header file. */
28-
#cmakedefine01 HAVE_MEMORY_H
29-
30-
/* Define to 1 if you have the <OpenGL/gl.h> header file. */
31-
#cmakedefine01 HAVE_OPENGL_GL_H
32-
33-
/* Define to 1 if you have the `posix_memalign' function. */
34-
#cmakedefine01 HAVE_POSIX_MEMALIGN
35-
36-
/* Have PTHREAD_PRIO_INHERIT. */
37-
#cmakedefine01 HAVE_PTHREAD_PRIO_INHERIT
38-
39-
/* Define to 1 if you have the <stdint.h> header file. */
40-
#cmakedefine HAVE_STDINT_H
41-
42-
/* Define to 1 if you have the <stdlib.h> header file. */
43-
#cmakedefine HAVE_STDLIB_H
44-
45-
/* Define to 1 if you have the <strings.h> header file. */
46-
#cmakedefine HAVE_STRINGS_H
47-
48-
/* Define to 1 if you have the <string.h> header file. */
49-
#cmakedefine HAVE_STRING_H
50-
51-
/* Define to 1 if you have the <sys/stat.h> header file. */
52-
#cmakedefine HAVE_SYS_STAT_H
53-
54-
/* Define to 1 if you have the <sys/types.h> header file. */
55-
#cmakedefine HAVE_SYS_TYPES_H
56-
57-
/* Define to 1 if you have the <unistd.h> header file. */
58-
#cmakedefine HAVE_UNISTD_H
59-
60-
/* Define to 1 if you have the <windows.h> header file. */
61-
#cmakedefine HAVE_WINDOWS_H
62-
63-
/* Define to 1 if you have the ANSI C header files. */
64-
#cmakedefine STDC_HEADERS
65-
663
/* Define USE_GLES */
674
#cmakedefine USE_GLES
685

696
/* Define PROJECTM_USE_THREADS */
707
#cmakedefine01 PROJECTM_USE_THREADS
718

729
/* Version number of package */
73-
#define VERSION "@PROJECT_VERSION@"
10+
#define VERSION "@libprojectM_VERSION@"
11+
12+
/* Boost or std filesystem API support */
13+
#cmakedefine PROJECTM_FILESYSTEM_USE_BOOST
14+
#define PROJECTM_FILESYSTEM_NAMESPACE @PROJECTM_FILESYSTEM_NAMESPACE@
15+
#define PROJECTM_FILESYSTEM_INCLUDE @PROJECTM_FILESYSTEM_INCLUDE@

features.cmake

+1-57
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,4 @@
1-
# Tests for various platform features and generates a header with the appropriate defines,
2-
# similar to the one created by autotools.
3-
4-
include(CheckSymbolExists)
5-
include(CheckCXXSymbolExists)
6-
include(CheckFunctionExists)
7-
include(CheckIncludeFileCXX)
8-
include(CheckEnumValueExists)
9-
include(CheckIncludeFiles)
1+
# Tests for various platform features and generates a header with the appropriate defines.
102
include(EnableCFlagsIfSupported)
113

124
add_compile_definitions(
@@ -33,54 +25,6 @@ else()
3325
)
3426
endif()
3527

36-
check_function_exists(aligned_alloc HAVE_ALIGNED_ALLOC)
37-
check_include_file_cxx("dlfcn.h" HAVE_DLFCN_H)
38-
check_include_file_cxx("fts.h" HAVE_FTS_H)
39-
check_include_file_cxx("GL/gl.h" HAVE_GL_GL_H)
40-
check_include_file_cxx("inttypes.h" HAVE_INTTYPES_H)
41-
check_include_file_cxx("memory.h" HAVE_MEMORY_H)
42-
check_function_exists(posix_memalign HAVE_POSIX_MEMALIGN)
43-
check_enum_value_exists("PTHREAD_PRIO_INHERIT" "pthread.h" HAVE_PTHREAD_PRIO_INHERIT)
44-
check_include_file_cxx("stdint.h" HAVE_STDINT_H)
45-
check_include_file_cxx("stdlib.h" HAVE_STDLIB_H)
46-
check_include_file_cxx("strings.h" HAVE_STRINGS_H)
47-
check_include_file_cxx("string.h" HAVE_STRING_H)
48-
check_include_file_cxx("sys/stat.h" HAVE_SYS_STAT_H)
49-
check_include_file_cxx("sys/types.h" HAVE_SYS_TYPES_H)
50-
check_include_file_cxx("unistd.h" HAVE_UNISTD_H)
51-
check_include_file_cxx("windows.h" HAVE_WINDOWS_H)
52-
53-
set(_std_c_headers
54-
# C89/C90
55-
assert.h
56-
ctype.h
57-
errno.h
58-
float.h
59-
limits.h
60-
locale.h
61-
math.h
62-
setjmp.h
63-
signal.h
64-
stdarg.h
65-
stddef.h
66-
stdio.h
67-
stdlib.h
68-
string.h
69-
time.h
70-
# C95/NA1
71-
iso646.h
72-
wctype.h
73-
# C99
74-
complex.h
75-
fenv.h
76-
inttypes.h
77-
stdbool.h
78-
stdint.h
79-
tgmath.h
80-
)
81-
check_include_files("${_std_c_headers}" STDC_HEADERS LANGUAGE C)
82-
unset(_std_c_headers)
83-
8428
# Adds fallback support to boost if std::filesystem is unavailable.
8529
include(FilesystemSupport)
8630

src/libprojectM/Renderer/FileScanner.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
#include <cctype>
55

66
// Fall back to boost if compiler doesn't support C++17
7-
#include FS_INCLUDE
8-
using namespace FS_NAMESPACE::filesystem;
7+
#include PROJECTM_FILESYSTEM_INCLUDE
8+
using namespace PROJECTM_FILESYSTEM_NAMESPACE::filesystem;
99

1010
namespace libprojectM {
1111
namespace Renderer {
@@ -49,7 +49,7 @@ void FileScanner::Scan(ScanCallback callback)
4949
for (const auto& entry : recursive_directory_iterator(basePath))
5050
{
5151
// Skip files without extensions and everything that's not a normal file.
52-
#ifdef FS_USING_BOOST
52+
#ifdef PROJECTM_FILESYSTEM_USE_BOOST
5353
if (!entry.path().has_extension() || (entry.status().type() != file_type::symlink_file && entry.status().type() != file_type::regular_file))
5454
#else
5555
if (!entry.path().has_extension() || (is_symlink(entry.status()) && is_regular_file(entry.status())))

src/playlist/Playlist.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
#include <algorithm>
44

55
// Fall back to boost if compiler doesn't support C++17
6-
#include FS_INCLUDE
7-
using namespace FS_NAMESPACE::filesystem;
6+
#include PROJECTM_FILESYSTEM_INCLUDE
7+
using namespace PROJECTM_FILESYSTEM_NAMESPACE::filesystem;
88

99
namespace libprojectM {
1010
namespace Playlist {

0 commit comments

Comments
 (0)