CMake: check if the compiler supports using precompiled headers
Build the cotire test project and check if it succeeds. Also check if the 'had text segment at different address' warning does not appear in the build output. If it does not succeed, disable usage of precompiled headers. If the PCH option was changed, clean the project and rebuild it again. Do not clean everytime the project is configured because (re)building the cotire test project takes some time.
This commit is contained in:
24
build/cmake/modules/cotire_test/src/example.cpp
Normal file
24
build/cmake/modules/cotire_test/src/example.cpp
Normal file
@@ -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
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user