Reputation: 18177
What is the equivalent of the following make file code in CMake?
target: config_header $(OBJS)
g++ -o $(APPNAME) $(OBJS) $(LIBDIR) $(LIBS)
config_header:
echo "#ifndef _CONFIG_HEADER_H_" > Config.h
echo "#define _CONFIG_HEADER_H_" >> Config.h
echo "#define MAJOR_VERSION \"$(MAJOR)\"" >> Config.h
echo "#define MINOR_VERSION \"$(MINOR)\"" >> Config.h
echo "#define PATCH_VERSION \"$(PATCH)\"" >> Config.h
echo "#define RELEASE_VERSION \"$(RELEASE)\"" >> Config.h
echo "#endif" >> Config.h
Upvotes: 1
Views: 437
Reputation: 7705
This copies your cmake config file to your binary directory and adapts the defined parameters.
#############################################################################
# Cmake generated header files
#############################################################################
CONFIGURE_FILE(
${CMAKE_CURRENT_SOURCE_DIR}/config.hpp.cmake
${CMAKE_CURRENT_BINARY_DIR}/config.hpp
)
The config.hpp.cmake file contains:
#ifndef GUARD
#define GUARD
#cmakedefine _CONFIG_HEADER_H_
#endif //GUARD
During the copy cmake generates the following file:
#ifndef GUARD
#define GUARD
#define _CONFIG_HEADER_H_
#endif //GUARD
Upvotes: 1