initial commit
Signed-off-by: Peter Siegmund <mars3142@noreply.mars3142.dev>
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
# cotire example project
|
||||
|
||||
add_executable(example main.cpp example.cpp log.cpp log.h example.h)
|
||||
|
||||
# enable warnings
|
||||
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
||||
set_target_properties(example PROPERTIES COMPILE_FLAGS "-Weverything")
|
||||
elseif (CMAKE_CXX_COMPILER_ID MATCHES "GNU")
|
||||
set_target_properties(example PROPERTIES COMPILE_FLAGS "-Wall -Wextra")
|
||||
endif()
|
||||
|
||||
cotire(example)
|
||||
|
||||
# cotire sets the following properties
|
||||
get_target_property(_unitySource example COTIRE_CXX_UNITY_SOURCE)
|
||||
get_target_property(_prefixHeader example COTIRE_CXX_PREFIX_HEADER)
|
||||
get_target_property(_precompiledHeader example COTIRE_CXX_PRECOMPILED_HEADER)
|
||||
get_target_property(_unityTargetName example COTIRE_UNITY_TARGET_NAME)
|
||||
|
||||
if (_unitySource)
|
||||
message(STATUS "example unity source: ${_unitySource}")
|
||||
endif()
|
||||
if (_prefixHeader)
|
||||
message(STATUS "example prefix header: ${_prefixHeader}")
|
||||
endif()
|
||||
if (_precompiledHeader)
|
||||
message(STATUS "example precompiled header: ${_precompiledHeader}")
|
||||
endif()
|
||||
if (TARGET ${_unityTargetName})
|
||||
message(STATUS "example unity target: ${_unityTargetName}")
|
||||
endif()
|
||||
@@ -0,0 +1,24 @@
|
||||
// cotire example project
|
||||
|
||||
#include "example.h"
|
||||
|
||||
#ifndef NDEBUG
|
||||
#include <algorithm>
|
||||
#include <iterator>
|
||||
#endif
|
||||
|
||||
namespace example {
|
||||
|
||||
std::string get_message() {
|
||||
char msg_chrs[] = { 'C', 'o', 't', 'i', 'r', 'e', 'd', '!' };
|
||||
#ifdef NDEBUG
|
||||
return std::string(&msg_chrs[0], &msg_chrs[sizeof(msg_chrs)]);
|
||||
#else
|
||||
std::string msg;
|
||||
msg.reserve(sizeof(msg_chrs));
|
||||
std::copy(msg_chrs, msg_chrs + sizeof(msg_chrs), std::back_inserter(msg));
|
||||
return msg;
|
||||
#endif
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
// cotire example project
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace example {
|
||||
|
||||
std::string get_message();
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
// cotire example project
|
||||
|
||||
#include "log.h"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
namespace logging {
|
||||
|
||||
void error(const std::string& msg) {
|
||||
std::cerr << msg << std::endl;
|
||||
}
|
||||
|
||||
void info(const std::string& msg) {
|
||||
std::cout << msg << std::endl;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
// cotire example project
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace logging {
|
||||
|
||||
void error(const std::string& msg);
|
||||
void info(const std::string& msg);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
// cotire example project main
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "example.h"
|
||||
#include "log.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
std::string msg = example::get_message();
|
||||
logging::info(msg);
|
||||
}
|
||||
Reference in New Issue
Block a user