libtabula

Check-in [05f15e2b1c]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Simplified the C++ feature testing mechanism some
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:05f15e2b1cad36639ba62dc3928a8710355f8f7e
User & Date: etr 2015-09-11 19:04:29
Context
2015-12-18
22:24
STL on OS X can't cope with vector::at() assignments when the space has only been set aside with vector::reserve(). It wants either a resize() call to set the space aside definitely, or push_back() to extend the vector into the reserved space. (This is probably a sanity check like the old SafeSTL, rather than an actual memory bug, but it has the same effect as a crash.) check-in: 24d069b506 user: tangent tags: trunk
2015-09-11
19:04
Simplified the C++ feature testing mechanism some check-in: 05f15e2b1c user: etr tags: trunk
18:47
Moved the configure_file() calls to the bottom of the top-level CMakeLists.txt file so they're after the recently-added C++11 tests. Otherwise, the wrong values get stored in src/config.h, and it can toggle on you, too. check-in: 650133871e user: etr tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to CMakeLists.txt.

134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
add_subdirectory(doc)
add_subdirectory(src)
add_subdirectory(src/ssx)
add_subdirectory(test)
add_subdirectory(examples)

# Check for specific post-C++98 features.  Must be after cmake subdir.
include(cmake/CheckCXX11Features.cmake)
CXX_CHECK_FEATURE("long long" HAVE_CXX_LONG_LONG)
CXX_CHECK_FEATURE("cbegin and cend" HAVE_CXX_CBEGIN_CEND)

# Two testing targets based on the dtest script, one running it
# standalone, one under CTest.  The latter suppresses output and 
# only reports pass/fail.  The dtest target can't depend on "all"
# due to a CMake design weakness, while "test" does implicitly,







<







134
135
136
137
138
139
140

141
142
143
144
145
146
147
add_subdirectory(doc)
add_subdirectory(src)
add_subdirectory(src/ssx)
add_subdirectory(test)
add_subdirectory(examples)

# Check for specific post-C++98 features.  Must be after cmake subdir.

CXX_CHECK_FEATURE("long long" HAVE_CXX_LONG_LONG)
CXX_CHECK_FEATURE("cbegin and cend" HAVE_CXX_CBEGIN_CEND)

# Two testing targets based on the dtest script, one running it
# standalone, one under CTest.  The latter suppresses output and 
# only reports pass/fail.  The dtest target can't depend on "all"
# due to a CMake design weakness, while "test" does implicitly,

Changes to cmake/CMakeLists.txt.




1
2
3
4
5
6
7
8
9
10
11
12
13
14
































































project("c++11_test")

# Does the compiler need special options to use post-C++98 features?
include(CheckCXXCompilerFlag)
CHECK_CXX_COMPILER_FLAG("-std=c++14" FOUND_CXX14)
CHECK_CXX_COMPILER_FLAG("-std=c++11" FOUND_CXX11)
CHECK_CXX_COMPILER_FLAG("-std=c++0x" FOUND_CXX0X)
if (FOUND_CXX14)
	set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14")
elseif (FOUND_CXX11)
	set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
elseif(COMPILER_SUPPORTS_CXX0X)
	set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
endif()





























































>
>
>
|













>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# This subproject extracts out some of the more complex tests from the
# top-level file, such as those that require attempted compilation.

project("cmake_compile_tests")

# Does the compiler need special options to use post-C++98 features?
include(CheckCXXCompilerFlag)
CHECK_CXX_COMPILER_FLAG("-std=c++14" FOUND_CXX14)
CHECK_CXX_COMPILER_FLAG("-std=c++11" FOUND_CXX11)
CHECK_CXX_COMPILER_FLAG("-std=c++0x" FOUND_CXX0X)
if (FOUND_CXX14)
	set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14")
elseif (FOUND_CXX11)
	set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
elseif(COMPILER_SUPPORTS_CXX0X)
	set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
endif()

# Define a macro to check for post-C++98 features, called from the top level
#
# Original version by Rolf Eike Beer
#
# Modifications by Andreas Weis: http://pageant.ghulbus.eu/?p=664
# Explicitly placed into the public domain
#
# Modified for libtabula, primarily by removing unneeded functionality.
MACRO(CXX_CHECK_FEATURE FEATURE_NAME RESULT_VAR)
	IF (NOT DEFINED ${RESULT_VAR})
		SET(LOG_NAME "\"${FEATURE_NAME}\"")
		string(REPLACE " " "_" BASE_NAME "c++-test-${FEATURE_NAME}")
		SET(BIN_DIR "${CMAKE_CURRENT_BINARY_DIR}/${BASE_NAME}")
		SET(SRC_FILE_BASE ${CMAKE_SOURCE_DIR}/cmake/${BASE_NAME})
		MESSAGE(STATUS "Checking for C++ ${LOG_NAME} feature...")

		SET(SRC_FILE "${SRC_FILE_BASE}.cpp")
		SET(SRC_FILE_FAIL "${SRC_FILE_BASE}_fail.cpp")
		SET(SRC_FILE_FAIL_COMPILE "${SRC_FILE_BASE}_fail_compile.cpp")

		IF (CROSS_COMPILING)
			try_compile(${RESULT_VAR} "${BIN_DIR}" "${SRC_FILE}")
			IF (${RESULT_VAR} AND EXISTS ${SRC_FILE_FAIL})
				try_compile(${RESULT_VAR} "${BIN_DIR}_fail" "${SRC_FILE_FAIL}")
			ENDIF (${RESULT_VAR} AND EXISTS ${SRC_FILE_FAIL})
		ELSE (CROSS_COMPILING)
			try_run(_RUN_RESULT_VAR _COMPILE_RESULT_VAR
					"${BIN_DIR}" "${SRC_FILE}")
			IF (_COMPILE_RESULT_VAR AND NOT _RUN_RESULT_VAR)
				SET(${RESULT_VAR} TRUE)
			ELSE (_COMPILE_RESULT_VAR AND NOT _RUN_RESULT_VAR)
				SET(${RESULT_VAR} FALSE)
			ENDIF (_COMPILE_RESULT_VAR AND NOT _RUN_RESULT_VAR)
			IF (${RESULT_VAR} AND EXISTS ${SRC_FILE_FAIL})
				try_run(_RUN_RESULT_VAR _COMPILE_RESULT_VAR
						"${BIN_DIR}_fail" "${SRC_FILE_FAIL}")
				IF (_COMPILE_RESULT_VAR AND _RUN_RESULT_VAR)
					SET(${RESULT_VAR} TRUE)
				ELSE (_COMPILE_RESULT_VAR AND _RUN_RESULT_VAR)
					SET(${RESULT_VAR} FALSE)
				ENDIF (_COMPILE_RESULT_VAR AND _RUN_RESULT_VAR)
			ENDIF (${RESULT_VAR} AND EXISTS ${SRC_FILE_FAIL})
		ENDIF (CROSS_COMPILING)
		IF (${RESULT_VAR} AND EXISTS ${SRC_FILE_FAIL_COMPILE})
			try_compile(_TMP_RESULT "${BIN_DIR}_fail_compile" "${SRC_FILE_FAIL_COMPILE}")
			IF (_TMP_RESULT)
				SET(${RESULT_VAR} FALSE)
			ELSE (_TMP_RESULT)
				SET(${RESULT_VAR} TRUE)
			ENDIF (_TMP_RESULT)
		ENDIF (${RESULT_VAR} AND EXISTS ${SRC_FILE_FAIL_COMPILE})

		IF (${RESULT_VAR})
			MESSAGE(STATUS "C++ ${LOG_NAME} feature supported")
		ELSE (${RESULT_VAR})
			MESSAGE(STATUS "C++ ${LOG_NAME} feature NOT supported")
		ENDIF (${RESULT_VAR})
		SET(${RESULT_VAR} ${${RESULT_VAR}} CACHE INTERNAL "C++ feature ${LOG_NAME}")
	ENDIF (NOT DEFINED ${RESULT_VAR})
ENDMACRO(CXX_CHECK_FEATURE)

Deleted cmake/CheckCXX11Features.cmake.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# Checks for post-C++98 features
#
# Original script by Rolf Eike Beer
#
# Modifications by Andreas Weis: http://pageant.ghulbus.eu/?p=664
# Explicitly placed into the public domain
#
# Modified for libtabula, primarily by removing unneeded functionality.

MACRO(CXX_CHECK_FEATURE FEATURE_NAME RESULT_VAR)
	IF (NOT DEFINED ${RESULT_VAR})
		SET(_LOG_NAME "\"${FEATURE_NAME}\"")
		string(REPLACE " " "_" BASE_NAME ${FEATURE_NAME})
		SET(_bindir "${CMAKE_CURRENT_BINARY_DIR}/cxx_${BASE_NAME}")
		SET(_SRCFILE_BASE ${CMAKE_SOURCE_DIR}/cmake/c++-test-${BASE_NAME})
		MESSAGE(STATUS "Checking for C++ ${_LOG_NAME} feature...")

		SET(_SRCFILE "${_SRCFILE_BASE}.cpp")
		SET(_SRCFILE_FAIL "${_SRCFILE_BASE}_fail.cpp")
		SET(_SRCFILE_FAIL_COMPILE "${_SRCFILE_BASE}_fail_compile.cpp")

		IF (CROSS_COMPILING)
			try_compile(${RESULT_VAR} "${_bindir}" "${_SRCFILE}")
			IF (${RESULT_VAR} AND EXISTS ${_SRCFILE_FAIL})
				try_compile(${RESULT_VAR} "${_bindir}_fail" "${_SRCFILE_FAIL}")
			ENDIF (${RESULT_VAR} AND EXISTS ${_SRCFILE_FAIL})
		ELSE (CROSS_COMPILING)
			try_run(_RUN_RESULT_VAR _COMPILE_RESULT_VAR
					"${_bindir}" "${_SRCFILE}")
			IF (_COMPILE_RESULT_VAR AND NOT _RUN_RESULT_VAR)
				SET(${RESULT_VAR} TRUE)
			ELSE (_COMPILE_RESULT_VAR AND NOT _RUN_RESULT_VAR)
				SET(${RESULT_VAR} FALSE)
			ENDIF (_COMPILE_RESULT_VAR AND NOT _RUN_RESULT_VAR)
			IF (${RESULT_VAR} AND EXISTS ${_SRCFILE_FAIL})
				try_run(_RUN_RESULT_VAR _COMPILE_RESULT_VAR
						"${_bindir}_fail" "${_SRCFILE_FAIL}")
				IF (_COMPILE_RESULT_VAR AND _RUN_RESULT_VAR)
					SET(${RESULT_VAR} TRUE)
				ELSE (_COMPILE_RESULT_VAR AND _RUN_RESULT_VAR)
					SET(${RESULT_VAR} FALSE)
				ENDIF (_COMPILE_RESULT_VAR AND _RUN_RESULT_VAR)
			ENDIF (${RESULT_VAR} AND EXISTS ${_SRCFILE_FAIL})
		ENDIF (CROSS_COMPILING)
		IF (${RESULT_VAR} AND EXISTS ${_SRCFILE_FAIL_COMPILE})
			try_compile(_TMP_RESULT "${_bindir}_fail_compile" "${_SRCFILE_FAIL_COMPILE}")
			IF (_TMP_RESULT)
				SET(${RESULT_VAR} FALSE)
			ELSE (_TMP_RESULT)
				SET(${RESULT_VAR} TRUE)
			ENDIF (_TMP_RESULT)
		ENDIF (${RESULT_VAR} AND EXISTS ${_SRCFILE_FAIL_COMPILE})

		IF (${RESULT_VAR})
			MESSAGE(STATUS "C++ ${_LOG_NAME} feature supported")
		ELSE (${RESULT_VAR})
			MESSAGE(STATUS "C++ ${_LOG_NAME} feature NOT supported")
		ENDIF (${RESULT_VAR})
		SET(${RESULT_VAR} ${${RESULT_VAR}} CACHE INTERNAL "C++ feature ${_LOG_NAME}")
	ENDIF (NOT DEFINED ${RESULT_VAR})
ENDMACRO(CXX_CHECK_FEATURE)
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<