Skip to content

Commit 6cf5d1e

Browse files
committed
CMake update
- variable usage, RPATHs, config header generation - remove the CMake core target
1 parent faadf26 commit 6cf5d1e

18 files changed

Lines changed: 336 additions & 82 deletions

File tree

CMakeLists.txt

Lines changed: 97 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,13 @@ set(SC_VERSION_MINOR 9)
4646
set(SC_VERSION_PATCH 1)
4747
set(SC_VERSION ${SC_VERSION_MAJOR}.${SC_VERSION_MINOR}.${SC_VERSION_PATCH})
4848

49+
# Set language standards
50+
set(CMAKE_C_EXTENSIONS OFF)
51+
set(CMAKE_C_STANDARD 11)
52+
set(CMAKE_C_STANDARD_REQUIRED ON)
53+
set(CMAKE_CXX_EXTENSIONS OFF)
54+
set(CMAKE_CXX_STANDARD 11)
55+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
4956

5057
# Minimum required version of CMake
5158
cmake_minimum_required(VERSION 3.6.3)
@@ -56,26 +63,101 @@ cmake_policy(SET CMP0057 NEW)
5663
# CMake derives much of its functionality from modules, typically
5764
# stored in one directory - let CMake know where to find them.
5865
set(SC_CMAKE_DIR "${SC_SOURCE_DIR}/cmake")
59-
if(NOT SC_IS_SUBBUILD)
60-
set(CMAKE_MODULE_PATH "${SC_CMAKE_DIR};${CMAKE_MODULE_PATH}")
61-
else(NOT SC_IS_SUBBUILD)
62-
set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH};${SC_CMAKE_DIR}")
63-
endif(NOT SC_IS_SUBBUILD)
66+
list(APPEND CMAKE_MODULE_PATH "${SC_CMAKE_DIR}")
67+
68+
# OpenBSD has its own naming conventions. Set a platform variable based on
69+
# the OS name so we can test for it succinctly.
70+
if ("${CMAKE_SYSTEM}" MATCHES ".*OpenBSD.*")
71+
set(OPENBSD ON)
72+
endif ("${CMAKE_SYSTEM}" MATCHES ".*OpenBSD.*")
73+
74+
#---------------------------------------------------------------------
75+
# Set up various relative path variables and build output directories
76+
include(Path_Setup)
77+
78+
#---------------------------------------------------------------------
79+
# The following logic is what allows binaries to run successfully in
80+
# the build directory AND install directory. Thanks to plplot for
81+
# identifying the necessity of setting CMAKE_INSTALL_NAME_DIR on OSX.
82+
# Documentation of these options is available at
83+
# http://www.cmake.org/Wiki/CMake_RPATH_handling
84+
85+
# use, i.e. don't skip the full RPATH for the build tree
86+
if(NOT DEFINED CMAKE_SKIP_BUILD_RPATH)
87+
set(CMAKE_SKIP_BUILD_RPATH FALSE)
88+
endif()
89+
90+
# when building, don't use the install RPATH already
91+
# (but later on when installing)
92+
if(NOT DEFINED CMAKE_BUILD_WITH_INSTALL_RPATH)
93+
set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
94+
endif()
95+
96+
# the RPATH/INSTALL_NAME_DIR to be used when installing
97+
if (NOT APPLE)
98+
if(NOT DEFINED CMAKE_INSTALL_RPATH)
99+
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib:\$ORIGIN/../lib")
100+
endif()
101+
endif(NOT APPLE)
102+
# On OSX, we need to set INSTALL_NAME_DIR instead of RPATH
103+
# http://www.cmake.org/cmake/help/cmake-2-8-docs.html#variable:CMAKE_INSTALL_NAME_DIR
104+
if(NOT DEFINED CMAKE_INSTALL_NAME_DIR)
105+
set(CMAKE_INSTALL_NAME_DIR "${CMAKE_INSTALL_PREFIX}/lib")
106+
endif()
107+
108+
# add the automatically determined parts of the RPATH which point to
109+
# directories outside the build tree to the install RPATH
110+
if(NOT DEFINED CMAKE_INSTALL_RPATH_USE_LINK_PATH)
111+
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
112+
endif()
113+
114+
115+
#---------------------------------------------------------------------
116+
# Build options
117+
option(BUILD_SHARED_LIBS "Build shared libraries" ON)
118+
option(BUILD_STATIC_LIBS "Build static libraries" OFF)
64119

65-
# testing and compilation options, build output dirs, install dirs, uninstall, package creation, etc
66-
include(${SC_CMAKE_DIR}/SC_Build_opts.cmake)
120+
option(SC_PYTHON_GENERATOR "Compile exp2python" ON)
121+
option(SC_CPP_GENERATOR "Compile exp2cxx" ON)
122+
123+
option(SC_MEMMGR_ENABLE_CHECKS "Enable sc_memmgr's memory leak detection" OFF)
124+
option(SC_TRACE_FPRINTF "Enable extra comments in generated code so the code's source in exp2cxx may be located" OFF)
125+
126+
option(SC_ENABLE_COVERAGE "Enable code coverage test" OFF)
127+
if (SC_ENABLE_COVERAGE AND ${CMAKE_C_COMPILER_ID} STREQUAL "GNU")
128+
set(CMAKE_C_FLAGS_DEBUG "-O0 -g -fprofile-arcs -ftest-coverage" CACHE STRING "Extra compile flags required by code coverage" FORCE)
129+
set(CMAKE_CXX_FLAGS_DEBUG "-O0 -g -fprofile-arcs -ftest-coverage" CACHE STRING "Extra compile flags required by code coverage" FORCE)
130+
set(CMAKE_MODULE_LINKER_FLAGS_DEBUG "-fprofile-arcs -ftest-coverage" CACHE STRING "Extra linker flags required by code coverage" FORCE)
131+
endif (SC_ENABLE_COVERAGE AND ${CMAKE_C_COMPILER_ID} STREQUAL "GNU")
132+
133+
option(SC_ENABLE_TESTING "Enable unittesting framework" OFF)
134+
if(SC_ENABLE_TESTING)
135+
if(NOT DEFINED SC_BUILD_SCHEMAS)
136+
set(SC_BUILD_SCHEMAS "ALL") #test all schemas, unless otherwise specified
137+
endif()
138+
include(CTest)
139+
endif(SC_ENABLE_TESTING)
140+
141+
# TODO - BRL-CAD is the only known user of this option, and it will be
142+
# transitioning to a new setup that won't need it - once that's done,
143+
# we should just remove this option.
144+
option(SC_SKIP_EXEC_INSTALL "Skip installing executables" OFF)
145+
mark_as_advanced(SC_SKIP_EXEC_INSTALL)
67146

68147
# SC_ADDEXEC and SC_ADDLIB macros, dllimport/export, etc
69-
include(${SC_CMAKE_DIR}/SC_Targets.cmake)
148+
include(SC_Targets)
70149

71150
# Macros related to paths
72-
include(${SC_CMAKE_DIR}/SC_Paths.cmake)
151+
include(SC_Paths)
73152

74153
# locale stuff
75-
include(${SC_CMAKE_DIR}/SC_Locale.cmake)
154+
include(SC_Locale)
76155

77156
# logic related to regenerating the lexer and parser source code
78-
include(${SC_CMAKE_DIR}/SC_Regenerate.cmake)
157+
include(SC_Regenerate)
158+
159+
# create config header sc_cf.h
160+
include(SC_Config_Headers)
79161

80162
if(NOT DEFINED SC_SDAI_ADDITIONAL_EXES_SRCS)
81163
set(SC_SDAI_ADDITIONAL_EXES_SRCS "" CACHE STRING "Source files for additional executables to be linked with SDAI libs")
@@ -86,7 +168,7 @@ if(NOT DEFINED SC_BUILD_SCHEMAS)
86168
"** CMake variable SC_BUILD_SCHEMAS was not set. Defaults to building ALL schemas, which will take a"
87169
" while; see http://stepcode.org/mw/index.php?title=STEPcode_CMake_variables#SC_BUILD_SCHEMAS")
88170
#this makes SC_BUILD_SCHEMAS show up in cmake-gui
89-
set(SC_BUILD_SCHEMAS "ALL" CACHE string "Semicolon-separated list of paths to EXPRESS schemas to be built")
171+
set(SC_BUILD_SCHEMAS "ALL" CACHE STRING "Semicolon-separated list of paths to EXPRESS schemas to be built")
90172
endif(NOT DEFINED SC_BUILD_SCHEMAS)
91173

92174
if(NOT SC_IS_SUBBUILD)
@@ -96,19 +178,17 @@ if(NOT SC_IS_SUBBUILD)
96178
".. Generating step can take a while if you are building several schemas.")
97179
endif(NOT SC_IS_SUBBUILD)
98180

99-
include(${SC_CMAKE_DIR}/SC_Config_Headers.cmake)
100181
# create config headers sc_cf.h
182+
include(SC_Config_Headers)
101183

102184

103185
################
104186

105-
set(CMAKE_C_STANDARD 11)
106-
set(CMAKE_CXX_STANDARD 11)
107-
108187
if(MSVC)
109188
# Disable warning for preferred usage of secure functions (example strcpy should be strcpy_s, ...)
110189
add_definitions(-D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_WARNINGS)
111-
else()
190+
endif()
191+
if (${CMAKE_C_COMPILER_ID} STREQUAL "GNU" OR ${CMAKE_C_COMPILER_ID} STREQUAL "Clang")
112192
add_definitions(-pedantic -W -Wall -Wundef -Wfloat-equal -Wshadow -Winline -Wno-long-long)
113193
endif()
114194

@@ -134,13 +214,6 @@ if(SC_ENABLE_TESTING)
134214
endif(SC_ENABLE_TESTING)
135215
add_subdirectory(doc)
136216

137-
# 'make core' builds everything that isn't generated. for devs.
138-
add_custom_target(core)
139-
if($CACHE{SC_BUILD_SHARED_LIBS})
140-
add_dependencies(core stepdai stepeditor exp2cxx check-express)
141-
else()
142-
add_dependencies(core stepdai-static stepeditor-static exp2cxx check-express)
143-
endif()
144217
if(NOT SC_IS_SUBBUILD)
145218
#-----------------------------------------------------------------------------
146219
# SC Packaging

cmake/Path_Setup.cmake

Lines changed: 164 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,164 @@
1+
# Copyright (c) 2010-2020 United States Government as represented by
2+
# the U.S. Army Research Laboratory.
3+
#
4+
# Redistribution and use in source and binary forms, with or without
5+
# modification, are permitted provided that the following conditions
6+
# are met:
7+
#
8+
# 1. Redistributions of source code must retain the above copyright
9+
# notice, this list of conditions and the following disclaimer.
10+
#
11+
# 2. Redistributions in binary form must reproduce the above
12+
# copyright notice, this list of conditions and the following
13+
# disclaimer in the documentation and/or other materials provided
14+
# with the distribution.
15+
#
16+
# 3. The name of the author may not be used to endorse or promote
17+
# products derived from this software without specific prior written
18+
# permission.
19+
#
20+
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
21+
# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
22+
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23+
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
24+
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25+
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
26+
# GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27+
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28+
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
29+
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
30+
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31+
32+
33+
#---------------------------------------------------------------------
34+
# Define relative install locations. Don't set these if they have already
35+
# been set by some other means (like a higher level CMakeLists.txt file
36+
# including this one).
37+
38+
# The location in which to install BRL-CAD executables.
39+
if(NOT BIN_DIR)
40+
set(BIN_DIR bin)
41+
endif(NOT BIN_DIR)
42+
43+
# Define a relative path that will "reset" a path back to
44+
# the point before BIN_DIR was appended. This is primarily
45+
# useful when working with generator expressions
46+
unset(RBIN_DIR CACHE)
47+
set(LBIN_DIR "${BIN_DIR}")
48+
while (NOT "${LBIN_DIR}" STREQUAL "")
49+
get_filename_component(LBDIR "${LBIN_DIR}" DIRECTORY)
50+
set(LBIN_DIR "${LBDIR}")
51+
if ("${RBIN_DIR}" STREQUAL "")
52+
set(RBIN_DIR "..")
53+
else ("${RBIN_DIR}" STREQUAL "")
54+
set(RBIN_DIR "../${RBIN_DIR}")
55+
endif ("${RBIN_DIR}" STREQUAL "")
56+
endwhile (NOT "${LBIN_DIR}" STREQUAL "")
57+
58+
# The location in which to install BRL-CAD libraries.
59+
if(NOT LIB_DIR)
60+
set(LIB_DIR lib)
61+
endif(NOT LIB_DIR)
62+
if(NOT LIBEXEC_DIR)
63+
set(LIBEXEC_DIR libexec)
64+
endif(NOT LIBEXEC_DIR)
65+
66+
# The location in which to install BRL-CAD header files.
67+
if(NOT INCLUDE_DIR)
68+
set(INCLUDE_DIR include)
69+
endif(NOT INCLUDE_DIR)
70+
71+
# The location in which to install BRL-CAD data files
72+
if(NOT DATA_DIR)
73+
set(DATA_DIR share)
74+
endif(NOT DATA_DIR)
75+
76+
# The location in which to install BRL-CAD documentation files
77+
if(NOT DOC_DIR)
78+
set(DOC_DIR ${DATA_DIR}/doc)
79+
endif(NOT DOC_DIR)
80+
81+
# The location in which to install BRL-CAD Manual pages
82+
if(NOT MAN_DIR)
83+
set(MAN_DIR ${DATA_DIR}/man)
84+
endif(NOT MAN_DIR)
85+
86+
# Make sure no absolute paths have been supplied to these variables
87+
set(INSTALL_DIRS BIN INCLUDE LIB LIBEXEC DATA MAN DOC)
88+
foreach(instdir ${INSTALL_DIRS})
89+
get_filename_component(instdir_full ${${instdir}_DIR} ABSOLUTE)
90+
if("${${instdir}_DIR}" STREQUAL "${instdir_full}")
91+
message(FATAL_ERROR "Error - absolute path supplied for ${instdir}_DIR. This path must be relative - e.g. \"bin\" instead of \"/usr/bin\"")
92+
set(HAVE_INSTALL_DIR_FULL_PATH 1)
93+
endif("${${instdir}_DIR}" STREQUAL "${instdir_full}")
94+
endforeach(instdir ${INSTALL_DIRS})
95+
96+
#---------------------------------------------------------------------
97+
# Output directories - this is where built library and executable
98+
# files will be placed after building but prior to install. The
99+
# necessary variables change between single and multi configuration
100+
# build systems, so it is necessary to handle both cases on a
101+
# conditional basis.
102+
103+
if(NOT CMAKE_CONFIGURATION_TYPES)
104+
# If we're not doing multi-configuration, just set the three main
105+
# variables to the correct values.
106+
if(NOT DEFINED CMAKE_LIBRARY_OUTPUT_DIRECTORY)
107+
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${${PROJECT_NAME}_BINARY_DIR}/${LIB_DIR} CACHE INTERNAL "Single output directory for building all libraries.")
108+
endif(NOT DEFINED CMAKE_LIBRARY_OUTPUT_DIRECTORY)
109+
if(NOT DEFINED CMAKE_ARCHIVE_OUTPUT_DIRECTORY)
110+
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${${PROJECT_NAME}_BINARY_DIR}/${LIB_DIR} CACHE INTERNAL "Single output directory for building all archives.")
111+
endif(NOT DEFINED CMAKE_ARCHIVE_OUTPUT_DIRECTORY)
112+
if(NOT DEFINED CMAKE_RUNTIME_OUTPUT_DIRECTORY)
113+
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${${PROJECT_NAME}_BINARY_DIR}/${BIN_DIR} CACHE INTERNAL "Single output directory for building all executables.")
114+
endif(NOT DEFINED CMAKE_RUNTIME_OUTPUT_DIRECTORY)
115+
else(NOT CMAKE_CONFIGURATION_TYPES)
116+
# Multi-configuration is more difficult. Not only do we need to
117+
# properly set the output directories, but we also need to
118+
# identify the "toplevel" directory for each configuration so
119+
# we can place files, documentation, etc. in the correct
120+
# relative positions. Because files may be placed by CMake
121+
# without a build target to put them in their proper relative build
122+
# directory position using these paths, we must fully qualify them
123+
# without using CMAKE_CFG_INTDIR.
124+
#
125+
# We define directories that may not be quite "standard"
126+
# for a particular build tool - for example, native VS2010 projects use
127+
# another directory to denote CPU type being compiled for - but CMake only
128+
# supports multi-configuration setups having multiple configurations,
129+
# not multiple compilers.
130+
#
131+
# One additional wrinkle we must watch for here is the case where
132+
# a multi-configuration setup uses "." for its internal directory -
133+
# if that's the case, we need to just set the various config output
134+
# directories to the same value.
135+
set(CFG_ROOT ${${PROJECT_NAME}_BINARY_DIR})
136+
foreach(CFG_TYPE ${CMAKE_CONFIGURATION_TYPES})
137+
if(NOT "${CMAKE_CFG_INTDIR}" STREQUAL ".")
138+
set(CFG_ROOT ${${PROJECT_NAME}_BINARY_DIR}/${CFG_TYPE})
139+
endif(NOT "${CMAKE_CFG_INTDIR}" STREQUAL ".")
140+
string(TOUPPER "${CFG_TYPE}" CFG_TYPE_UPPER)
141+
if(NOT DEFINED CMAKE_LIBRARY_OUTPUT_DIRECTORY_${CFG_TYPE_UPPER})
142+
set("CMAKE_LIBRARY_OUTPUT_DIRECTORY_${CFG_TYPE_UPPER}" ${CFG_ROOT}/${LIB_DIR} CACHE INTERNAL "Single output directory for building ${CFG_TYPE} libraries.")
143+
endif(NOT DEFINED CMAKE_LIBRARY_OUTPUT_DIRECTORY_${CFG_TYPE_UPPER})
144+
if(NOT DEFINED CMAKE_ARCHIVE_OUTPUT_DIRECTORY_${CFG_TYPE_UPPER})
145+
set("CMAKE_ARCHIVE_OUTPUT_DIRECTORY_${CFG_TYPE_UPPER}" ${CFG_ROOT}/${LIB_DIR} CACHE INTERNAL "Single output directory for building ${CFG_TYPE} archives.")
146+
endif(NOT DEFINED CMAKE_ARCHIVE_OUTPUT_DIRECTORY_${CFG_TYPE_UPPER})
147+
if(NOT DEFINED CMAKE_RUNTIME_OUTPUT_DIRECTORY_${CFG_TYPE_UPPER})
148+
set("CMAKE_RUNTIME_OUTPUT_DIRECTORY_${CFG_TYPE_UPPER}" ${CFG_ROOT}/${BIN_DIR} CACHE INTERNAL "Single output directory for building ${CFG_TYPE} executables.")
149+
endif(NOT DEFINED CMAKE_RUNTIME_OUTPUT_DIRECTORY_${CFG_TYPE_UPPER})
150+
if(NOT DEFINED CMAKE_BINARY_DIR_${CFG_TYPE_UPPER})
151+
set("CMAKE_BINARY_DIR_${CFG_TYPE_UPPER}" ${CFG_ROOT} CACHE INTERNAL "Toplevel binary dir for ${CFG_TYPE} building.")
152+
endif(NOT DEFINED CMAKE_BINARY_DIR_${CFG_TYPE_UPPER})
153+
if(NOT DEFINED ${PROJECT_NAME}_BINARY_DIR_${CFG_TYPE_UPPER})
154+
set("${PROJECT_NAME}_BINARY_DIR_${CFG_TYPE_UPPER}" ${CFG_ROOT} CACHE INTERNAL "Toplevel binary dir for ${CFG_TYPE} building.")
155+
endif(NOT DEFINED ${PROJECT_NAME}_BINARY_DIR_${CFG_TYPE_UPPER})
156+
endforeach()
157+
endif(NOT CMAKE_CONFIGURATION_TYPES)
158+
159+
# Local Variables:
160+
# tab-width: 8
161+
# mode: cmake
162+
# indent-tabs-mode: t
163+
# End:
164+
# ex: shiftwidth=2 tabstop=8

cmake/SC_CXX_schema_macros.cmake

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ macro(SCHEMA_TARGETS expFile schemaName sourceFiles)
9393
${SC_SOURCE_DIR}/src/base/judy/src
9494
)
9595
# if testing is enabled, "TESTABLE" sets property EXCLUDE_FROM_ALL and prevents installation
96-
if($CACHE{SC_BUILD_SHARED_LIBS})
96+
if(BUILD_SHARED_LIBS)
9797
SC_ADDLIB(${PROJECT_NAME} SHARED SOURCES ${sourceFiles} LINK_LIBRARIES stepdai stepcore stepeditor steputils base TESTABLE)
9898
add_dependencies(${PROJECT_NAME} generate_cpp_${PROJECT_NAME})
9999
if(WIN32)
@@ -102,6 +102,12 @@ macro(SCHEMA_TARGETS expFile schemaName sourceFiles)
102102
target_compile_options("${PROJECT_NAME}" PRIVATE "/bigobj")
103103
endif()
104104
endif()
105+
# TODO - ideally we would avoid generating code that triggers this warning, but figuring out
106+
# how to do so is a non-trivial exercise. In the meantime, suppress the (very verbose) warnings
107+
# we get due to this issue so it doesn't mask other problems.
108+
if(${CMAKE_C_COMPILER_ID} STREQUAL "GNU")
109+
target_compile_options("${PROJECT_NAME}" PRIVATE "-Wno-ignored-qualifiers")
110+
endif()
105111
endif()
106112
107113
if($CACHE{SC_BUILD_STATIC_LIBS})

cmake/SC_Config_Headers.cmake

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,3 @@
1-
2-
# Take the sc config file template as the starting point for
3-
# sc_cf.h.in - scripts may need to append to the template, so
4-
# it is read into memory initially.
5-
set(CONFIG_H_FILE ${SC_BINARY_DIR}/include/sc_cf.h.in)
6-
set_source_files_properties(${CONFIG_H_FILE} PROPERTIES GENERATED TRUE)
7-
set(CMAKE_CURRENT_PROJECT SC)
8-
define_property(GLOBAL PROPERTY SC_CONFIG_H_CONTENTS BRIEF_DOCS "config.h.in contents" FULL_DOCS "config.h.in contents for SC project")
9-
if(NOT COMMAND CONFIG_H_APPEND)
10-
macro(CONFIG_H_APPEND PROJECT_NAME NEW_CONTENTS)
11-
if(PROJECT_NAME)
12-
get_property(${PROJECT_NAME}_CONFIG_H_CONTENTS GLOBAL PROPERTY ${PROJECT_NAME}_CONFIG_H_CONTENTS)
13-
set(${PROJECT_NAME}_CONFIG_H_FILE_CONTENTS "${${PROJECT_NAME}_CONFIG_H_CONTENTS}${NEW_CONTENTS}")
14-
set_property(GLOBAL PROPERTY ${PROJECT_NAME}_CONFIG_H_CONTENTS "${${PROJECT_NAME}_CONFIG_H_FILE_CONTENTS}")
15-
endif(PROJECT_NAME)
16-
endmacro(CONFIG_H_APPEND NEW_CONTENTS)
17-
endif(NOT COMMAND CONFIG_H_APPEND)
18-
file(READ ${SC_SOURCE_DIR}/include/sc_cf_cmake.h.in CONFIG_H_FILE_CONTENTS)
19-
CONFIG_H_APPEND(SC "${CONFIG_H_FILE_CONTENTS}")
201
# create sc_cf.h
212

223
include(CheckLibraryExists)
@@ -97,10 +78,8 @@ int main() {return !(f() == f());}
9778
endif(SC_ENABLE_CXX11)
9879

9980
# Now that all the tests are done, configure the sc_cf.h file:
100-
get_property(CONFIG_H_FILE_CONTENTS GLOBAL PROPERTY SC_CONFIG_H_CONTENTS)
101-
file(WRITE ${CONFIG_H_FILE} "${CONFIG_H_FILE_CONTENTS}")
102-
configure_file(${CONFIG_H_FILE} ${SC_BINARY_DIR}/${INCLUDE_INSTALL_DIR}/sc_cf.h)
103-
81+
configure_file(${CMAKE_SOURCE_DIR}/include/sc_cf.h.in ${SC_BINARY_DIR}/${INCLUDE_DIR}/sc_cf.h.gen)
82+
execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different ${SC_BINARY_DIR}/${INCLUDE_DIR}/sc_cf.h.gen ${SC_BINARY_DIR}/${INCLUDE_DIR}/sc_cf.h)
10483

10584
# Local Variables:
10685
# tab-width: 8

0 commit comments

Comments
 (0)