{"id":6328,"date":"2019-08-04T21:59:56","date_gmt":"2019-08-04T12:59:56","guid":{"rendered":"https:\/\/theolizer.com\/wordpress\/?p=6328"},"modified":"2019-12-01T17:56:00","modified_gmt":"2019-12-01T08:56:00","slug":"cpp-school3-11","status":"publish","type":"post","link":"https:\/\/theolizer.com\/cpp-school3\/cpp-school3-11\/","title":{"rendered":"\u7b2c11\u56de \u7d50\u69cb\u4fbf\u5229\u306aconfigure_file"},"content":{"rendered":"<p>\u3053\u3093\u306b\u3061\u306f\u3002\u7530\u539f\u3067\u3059\u3002<\/p>\n<p>\u4eca\u5e74\u3082\u3044\u3088\u3044\u3088\u672c\u683c\u7684\u306a\u590f\u304c\u6765\u307e\u3057\u305f\u306d\u3002\u3044\u3084\u3001\u672c\u5f53\u306b\u6691\u3044\u3067\u3059\u3002<br \/>\n\u3055\u3066\u3001\u4eca\u56de\u306f\u304a\u624b\u8efd\u306b\u30c6\u30ad\u30b9\u30c8\u30fb\u30d5\u30a1\u30a4\u30eb\u3092\u52a0\u5de5\u3067\u304d\u308bconfigure_file\u30b3\u30de\u30f3\u30c9\u306b\u3064\u3044\u3066\u8aac\u660e\u3057\u307e\u3059\u3002\u30d0\u30a4\u30ca\u30ea\u306e\u30d5\u30a1\u30a4\u30eb\u540d\u3084\u30d0\u30fc\u30b8\u30e7\u30f3\u540d\u306a\u3069\u8907\u6570\u306e\u30bd\u30fc\u30b9\u3078\u53cd\u6620\u3057\u305f\u3044\u69d8\u3005\u306a\u8a2d\u5b9a\u3092\uff11\u7b87\u6240\u306b\u307e\u3068\u3081\u305f\u3044\u6642\u306a\u3069\u306b\u3088\u304f\u4f7f\u3063\u3066\u3044\u307e\u3059\u3002\u304a\u624b\u8efd\u3067\u4fbf\u5229\u3067\u3059\u3088\u3002<\/p>\n<h3>\uff11\uff0e\u6982\u8981<\/h3>\n<p>\u307e\u305a\u3001\u3053\u306e\u30b3\u30de\u30f3\u30c9\u306f\u30c6\u30ad\u30b9\u30c8\u30fb\u30d5\u30a1\u30a4\u30eb\u3092\u8aad\u307f\u8fbc\u3093\u3067\u52a0\u5de5\u3057\u3066\u30c6\u30ad\u30b9\u30c8\u30fb\u30d5\u30a1\u30a4\u30eb\u3078\u51fa\u529b\u3059\u308b\u3082\u306e\u3067\u3059\u3002<br \/>\n\u3069\u3093\u306a\u52a0\u5de5\u3059\u308b\u306e\u304b\uff1f\u3067\u3059\u304c\u3001\u5358\u7d14\u3067\u3059\u3002\u5165\u529b\u30c6\u30ad\u30b9\u30c8\u30fb\u30d5\u30a1\u30a4\u30eb\u306b\u3042\u308b\u6587\u5b57\u5217\u300c${CMake\u5909\u6570\u540d}\u300d\u3068\u300c@CMake\u5909\u6570\u540d@\u300d\u3092\u305d\u306eCMake\u5909\u6570\u306e\u5024\u3067\u7f6e\u63db\u3057\u3001\u6307\u5b9a\u306e\u30c6\u30ad\u30b9\u30c8\u30fb\u30d5\u30a1\u30a4\u30eb\u3078\u51fa\u529b\u3057\u307e\u3059\u3002<br \/>\n\u3082\u3057\u3001\u5f53\u8a72CMake\u5909\u6570\u304c\u5b9a\u7fa9\u3055\u308c\u3066\u306a\u304b\u3063\u305f\u3089\u7a7a\u6587\u5b57\u5217\u3078\u7f6e\u63db\u3055\u308c\u307e\u3059\u3002<\/p>\n<pre class=\"brush: plain; title: sample.cpp.in; notranslate\" title=\"sample.cpp.in\">\r\n#define APP_NAME\t&quot;@APP_NAME@&quot;\r\n#define VERSION_NO\t&quot;${APP_VERSION}&quot;\r\n#define\tDUMMY\t\t&quot;${DUMMY}&quot;\r\n<\/pre>\n<pre class=\"brush: plain; title: sample.cmake; notranslate\" title=\"sample.cmake\">\r\nset(APP_NAME    &quot;SampleApplication&quot;)\r\nset(APP_VERSION &quot;1.0.0&quot;)\r\nunset(DUMMY)\r\n\r\nconfigure_file(sample.cpp.in sample1.cpp)\r\n<\/pre>\n<p><code>cmake -P sample.cmake<\/code> \u3092\u5b9f\u884c\u3059\u308b\u3068 sample1.cpp \u304c\u51fa\u529b\u3055\u308c\u307e\u3059\u3002<\/p>\n<pre class=\"brush: plain; title: sample1.cpp; notranslate\" title=\"sample1.cpp\">\r\n#define APP_NAME\t&quot;SampleApplication&quot;\r\n#define VERSION_NO\t&quot;1.0.0&quot;\r\n#define\tDUMMY\t\t&quot;&quot;\r\n<\/pre>\n<p>\u307e\u305f\u3001configure_file\u306f\u30b9\u30af\u30ea\u30d7\u30c8\u30fb\u30e2\u30fc\u30c9\u306e\u30b3\u30de\u30f3\u30c9\u3067\u3059\u306e\u3067Makefile\u751f\u6210\u30e2\u30fc\u30c9\u3001\u30b9\u30af\u30ea\u30d7\u30c8\u30fb\u30e2\u30fc\u30c9\u306e\u4e21\u65b9\u3067\u6a5f\u80fd\u3057\u307e\u3059\u3002<\/p>\n<h3>\uff12\uff0e\u8a73\u7d30<\/h3>\n<p>\u3053\u306e\u30b3\u30de\u30f3\u30c9\u306f\u30d1\u30e9\u30e1\u30fc\u30bf\u306f\u5c11\u3057\u3057\u304b\u3042\u308a\u307e\u305b\u3093\u3002<br \/>\n\u66f8\u5f0f\u306f\u3001<a href=\"https:\/\/cmake.org\/cmake\/help\/latest\/command\/configure_file.html\" rel=\"noopener noreferrer\" target=\"_blank\">\u516c\u5f0f\u306e\u89e3\u8aac<\/a>\u306b\u6b21\u306e\u3088\u3046\u306b\u66f8\u304b\u308c\u3066\u3044\u307e\u3059\u3002<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\nconfigure_file(&lt;input&gt; &lt;output&gt;\r\n               &#x5B;COPYONLY] &#x5B;ESCAPE_QUOTES] &#x5B;@ONLY]\r\n               &#x5B;NEWLINE_STYLE &#x5B;UNIX|DOS|WIN32|LF|CRLF] ])\r\n<\/pre>\n<p><code>&lt;input&gt;<\/code> \u306f\u5165\u529b\u5074\u306e\u30c6\u30ad\u30b9\u30c8\u30fb\u30d5\u30a1\u30a4\u30eb\u306e\u30d1\u30b9\u540d\u3067\u3059\u3002<br \/>\n<code>&lt;output&gt;<\/code> \u306f\u51fa\u529b\u5074\u306e\u30c6\u30ad\u30b9\u30c8\u30fb\u30d5\u30a1\u30a4\u30eb\u306e\u30d1\u30b9\u540d\u3067\u3059\u3002<br \/>\n\u3053\u306e\uff12\u3064\u306f\u7701\u7565\u3067\u304d\u307e\u305b\u3093\u3002<\/p>\n<h4>2-1. @ONLY<span id=\"@ONLY\"\/><\/h4>\n<p>configure_file\u306f\u30c7\u30d5\u30a9\u30eb\u30c8\u3067\u306f\u3001\u300c${CMake\u5909\u6570\u540d}\u300d\u3068\u300c@CMake\u5909\u6570\u540d@\u300d\u306e\u4e21\u65b9\u306e\u6587\u5b57\u5217\u3092\u7f6e\u63db\u3057\u307e\u3059\u304c\u3001\u3053\u306e\u30aa\u30d7\u30b7\u30e7\u30f3\u3092\u6307\u5b9a\u3059\u308b\u3068\u8aad\u3093\u3067\u5b57\u306e\u5982\u304f\u300c@CMake\u5909\u6570\u540d@\u300d\u3060\u3051\u3092\u7f6e\u63db\u3057\u307e\u3059\u3002<\/p>\n<p>\u4f8b\u3048\u3070bash\u30b9\u30af\u30ea\u30d7\u30c8\u306f <a href=\"https:\/\/shellscript.sunone.me\/variable.html#%E5%A4%89%E6%95%B0%E3%81%AE%E5%80%A4%E3%82%92%E5%8F%82%E7%85%A7%E3%81%99%E3%82%8B\" rel=\"noopener noreferrer\" target=\"_blank\">${\u5909\u6570\u540d} \u3068\u3044\u3046\u8a18\u8ff0\u3067\u3082bash\u5909\u6570\u3092\u53c2\u7167<\/a>\u3057\u307e\u3059\u3002\u3067\u3059\u306e\u3067\u3001bash\u30b9\u30af\u30ea\u30d7\u30c8\u306b\u306f\u300c@{\u5909\u6570\u540d}\u300d\u306e\u3088\u3046\u306a\u8a18\u8ff0\u304c\u591a\u6570\u3042\u308a\u3001configure_file\u306b\u5165\u529b\u3059\u308b\u3068\u7f6e\u63db\u3055\u308c\u308b\u306e\u3067\u56f0\u3063\u305f\u3053\u3068\u306b\u306a\u308a\u307e\u3059\u3002\u305d\u306e\u3088\u3046\u306a\u6642 @ONLY \u30aa\u30d7\u30b7\u30e7\u30f3\u3092\u6307\u5b9a\u3057\u3066\u3001\u300c${CMake\u5909\u6570\u540d}\u300d\u3092\u7f6e\u63db\u3057\u306a\u3044\u3088\u3046\u306b\u3057\u307e\u3059\u3002<\/p>\n<h4>2-2. NEWLINE_STYLE<\/h4>\n<p>NEWLINE_STYLE\u306f\u3001\u51fa\u529b\u3059\u308b\u30c6\u30ad\u30b9\u30c8\u30fb\u30d5\u30a1\u30a4\u30eb\u306e\u6539\u884c\u30b3\u30fc\u30c9\u3092\u6307\u5b9a\u3059\u308b\u3082\u306e\u3067\u3059\u3002<br \/>\nNEWLINE_STYLE\u30aa\u30d7\u30b7\u30e7\u30f3\u3092\u6307\u5b9a\u3057\u306a\u304b\u3063\u305f\u5834\u5408\u306f\u3001\u4f7f\u3063\u3066\u3044\u308bOS\u306e\u6a19\u6e96\u306e\u30b3\u30fc\u30c9\u3068\u306a\u308a\u307e\u3059\u3002<br \/>\n\u5bfe\u5fdc\u3057\u3066\u3044\u308b\u6539\u884c\u30b3\u30fc\u30c9\u306f\u3001LF(0A)\u3001CRLF(0D0A)\u306e\uff12\u7a2e\u985e\u3060\u3051\u306e\u3088\u3046\u3067\u3059\u3002<\/p>\n<table>\n<thead>\n<tr>\n<th>NEWLINE_STYLE<\/th>\n<th>\u6539\u884c\u30b3\u30fc\u30c9<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>UNIX<\/td>\n<td>LF (0A)<\/td>\n<\/tr>\n<tr>\n<td>LF<\/td>\n<td>LF (0A)<\/td>\n<\/tr>\n<tr>\n<td>DOS<\/td>\n<td>CRLF (0D0A)<\/td>\n<\/tr>\n<tr>\n<td>WIN32<\/td>\n<td>CRLF (0D0A)<\/td>\n<\/tr>\n<tr>\n<td>CRLF<\/td>\n<td>CRLF (0D0A)<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>Mac\u306eCR\u306b\u306f\u5bfe\u5fdc\u3057\u3066\u3044\u307e\u305b\u3093\u3002configure_file\u306f\u3001Mac\u4ee5\u5916\u306eOS\u3067Mac\u6539\u884c\u30b3\u30fc\u30c9\u306e\u30c6\u30ad\u30b9\u30c8\u30fb\u30d5\u30a1\u30a4\u30eb\u3092\u51fa\u529b\u3067\u304d\u306a\u3044\u3068\u3044\u3046\u3053\u3068\u3067\u3059\u3002<\/p>\n<h4>2-3. COPYONLY<span id=\"copyonly\"\/><\/h4>\n<p>\u3053\u308c\u306f\u6587\u5b57\u5217\u306e\u7f6e\u63db\u3092\u4e00\u5207\u884c\u308f\u305a\u3001\u5165\u529b\u30d5\u30a1\u30a4\u30eb\u3092\u51fa\u529b\u30d5\u30a1\u30a4\u30eb\u3078\u5358\u7d14\u306b\u30b3\u30d4\u30fc\u3057\u307e\u3059\u3002<br \/>\n\u3061\u3087\u3063\u3068\u6b8b\u5ff5\u306a\u3053\u3068\u306bCOPYONLY\u3092\u6307\u5b9a\u3057\u305f\u6642\u3001NEWLINE_STYLE\u306f\u6a5f\u80fd\u3057\u307e\u305b\u3093\u3002\u3064\u307e\u308a\u3001\u6539\u884c\u30b3\u30fc\u30c9\u3060\u3051\u3092\u4fee\u6b63\u3057\u3001\u305d\u306e\u4ed6\u306e\u6587\u5b57\u5217\u3092\u9593\u9055\u3063\u3066\u7f6e\u63db\u3057\u305f\u304f\u306a\u3044\u3088\u3046\u306a\u6642\u306bconfigure_file\u306f\u4f7f\u3048\u307e\u305b\u3093\u3002<\/p>\n<h4>2-4. ESCAPE_QUOTES<\/h4>\n<p>\u3053\u306e\u30aa\u30d7\u30b7\u30e7\u30f3\u306f\u5206\u304b\u308a\u306b\u304f\u3044\u3067\u3059\u3002<a href=\"https:\/\/cmake.org\/cmake\/help\/latest\/command\/configure_file.html\" rel=\"noopener noreferrer\" target=\"_blank\">\u516c\u5f0f\u306e\u8aac\u660e\u306f\u6b21\u306e\u3088\u3046\u306b\u66f8\u304b\u308c\u3066\u3044\u307e\u3059<\/a>\u3002<\/p>\n<blockquote><p>ESCAPE_QUOTES<span id=\"ESCAPE_QUOTES\"\/><br \/>\n\u3000\u3000Escape any substituted quotes with backslashes (C-style).<br \/>\n\u3000\u3000\u30d0\u30c3\u30af\u30b9\u30e9\u30c3\u30b7\u30e5\u3092\u4f7f\u7528\u3057\u3066\u7f6e\u63db\u5f15\u7528\u7b26\u3092\u30a8\u30b9\u30b1\u30fc\u30d7\u3057\u307e\u3059\uff08C\u30b9\u30bf\u30a4\u30eb\uff09\u3002\uff08Google\u7ffb\u8a33\uff09<br \/>\n\u3000\u3000\u7f6e\u63db\u5f8c\u306e\u30c0\u30d6\u30eb\u30b3\u30fc\u30c6\u30fc\u30b7\u30e7\u30f3\u3092\u30d0\u30c3\u30af\u30b9\u30e9\u30c3\u30b7\u30e5\u3067\u30a8\u30b9\u30b1\u30fc\u30d7\u3057\u307e\u3059\u3002\uff08\u8abf\u67fb\u3057\u3066\u610f\u8a33\uff09\n<\/p><\/blockquote>\n<p>\u30a4\u30f3\u30bf\u30fc\u30cd\u30c3\u30c8\u3092\u3042\u308c\u3053\u308c\u691c\u7d22\u3057\u3066\u307f\u307e\u3057\u305f\u304c\u3001\u8a73\u3057\u3044\u89e3\u8aac\u3092\u898b\u3064\u3051\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u305b\u3093\u3067\u3057\u305f\u3002\u305d\u3053\u3067\u3001\u3042\u308c\u3053\u308c\u3084\u3063\u3066\u632f\u308b\u821e\u3044\u3092\u8abf\u3079\u3066\u307f\u307e\u3057\u305f\u3002<br \/>\n\u7d50\u8ad6\u3068\u3057\u3066\u306f\u3001CMake\u5909\u6570\u5185\u306b &#8220;\uff08\u30c0\u30d6\u30eb\u30b3\u30fc\u30c6\u30fc\u30b7\u30e7\u30f3\uff09\u304c\u6709\u3063\u305f\u5834\u5408\u3001\u30d0\u30c3\u30af\u30b9\u30e9\u30c3\u30b7\u30e5\u3067\u30a8\u30b9\u30b1\u30fc\u30d7\u3059\u308b\u3068\u3044\u3046\u30aa\u30d7\u30b7\u30e7\u30f3\u306e\u3088\u3046\u3067\u3059\u3002<\/p>\n<p>\u4f8b\u3048\u3070\u3001FOO\u5909\u6570\u306b \u300cabc&#8221;def\u300d \u3068\u3044\u3046\u6587\u5b57\u5217\uff08\u30c0\u30d6\u30eb\u30b3\u30fc\u30c6\u30fc\u30b7\u30e7\u30f3\u304c\u771f\u3093\u4e2d\u306b\uff11\u3064\uff09\u304c\u8a2d\u5b9a\u3055\u308c\u3066\u3044\u308b\u6642\u306b\u3001\u300c${FOO}\u300d\u306f\u300cabc\\&#8221;def\u300d\u3078\u7f6e\u63db\u3055\u308c\u307e\u3059\u3002<br \/>\n\u56e0\u307f\u306b\u30b7\u30f3\u30b0\u30eb\u30b3\u30fc\u30c6\u30fc\u30b7\u30e7\u30f3\u306f\u30a8\u30b9\u30b1\u30fc\u30d7\u3055\u308c\u307e\u305b\u3093\u3067\u3057\u305f\u3002<\/p>\n<pre class=\"brush: plain; title: escape_quotes.txt.in; notranslate\" title=\"escape_quotes.txt.in\">\r\nESCAPE_QUOTES : ${FOO}\r\n<\/pre>\n<pre class=\"brush: plain; title: escape_quotes.cmake; notranslate\" title=\"escape_quotes.cmake\">\r\nset(FOO abc\\&quot;def'ghi) # FOO\u306e\u5185\u5bb9\u306f\u300cabc&quot;def'ghi\u300d\r\n\r\nconfigure_file(escape_quotes.txt.in escape_quotes1.txt)\r\nconfigure_file(escape_quotes.txt.in escape_quotes2.txt ESCAPE_QUOTES)\r\n<\/pre>\n<p><code>cmake -P escape_quotes.cmake<\/code> \u3092\u5b9f\u884c\u3059\u308b\u3068 escape_quotes1.txt \u3068 escape_quotes2.txt \u304c\u51fa\u529b\u3055\u308c\u307e\u3059\u3002<\/p>\n<pre class=\"brush: plain; title: escape_quotes1.txt; notranslate\" title=\"escape_quotes1.txt\">\r\nESCAPE_QUOTES : abc&quot;def'ghi\r\n<\/pre>\n<pre class=\"brush: plain; title: escape_quotes2.txt; notranslate\" title=\"escape_quotes2.txt\">\r\nESCAPE_QUOTES : abc\\&quot;def'ghi\r\n<\/pre>\n<p>ESCAPE_QUOTES\u3092\u6307\u5b9a\u3059\u308b\u3068CMake\u5909\u6570\u306a\u3044\u306e &#8220;\uff08\u30c0\u30d6\u30eb\u30b3\u30fc\u30c6\u30fc\u30b7\u30e7\u30f3\uff09\u304c \\\uff08\u30d0\u30c3\u30af\u30b9\u30e9\u30c3\u30b7\u30e5\uff1d\u65e5\u672c\u8a9e\u30d5\u30a9\u30f3\u30c8\u306a\u3089\u5186\u30de\u30fc\u30af\uff09\u3067\u30a8\u30b9\u30b1\u30fc\u30d7\u3055\u308c\u3066\u3044\u307e\u3059\u3002<\/p>\n<h4>2-5. \u3042\u308a\u304c\u305f\u3044\u8ffd\u52a0\u4ed5\u69d8<\/h4>\n<p>\u4ed6\u306b\u3042\u308a\u304c\u305f\u3044\u4ed5\u69d8\u304c\u3042\u308a\u307e\u3059\u3002configure_file\u3067\u751f\u6210\u3055\u308c\u305f\u51fa\u529b\u30d5\u30a1\u30a4\u30eb\u304c\u524d\u56de\u306e\u3082\u306e\u3068\u5909\u5316\u304c\u306a\u304b\u3063\u305f\u6642\u3001\u4e0a\u66f8\u304d\u3057\u306a\u3044\u3088\u3046\u3067\u3059\u3002\u305d\u306e\u305f\u3081\u51fa\u529b\u30d5\u30a1\u30a4\u30eb\u306e\u6700\u7d42\u66f4\u65b0\u65e5\u6642\u304c\u5909\u308f\u308a\u307e\u305b\u3093\u3002<\/p>\n<p>\u901a\u5e38\u306e\u30d3\u30eb\u30c9\u30fb\u30b7\u30b9\u30c6\u30e0\u306f\u30bd\u30fc\u30b9\u30fb\u30d5\u30a1\u30a4\u30eb\u3088\u308a\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u30fb\u30d5\u30a1\u30a4\u30eb\u306e\u65b9\u304c\u65b0\u3057\u3044\u6642\uff08\u30bd\u30fc\u30b9\u30fb\u30d5\u30a1\u30a4\u30eb\u66f4\u65b0\u5f8c\u3001\u30b3\u30f3\u30d1\u30a4\u30eb\u3055\u308c\u3066\u3044\u306a\u3044\u6642\uff09\u3060\u3051\u30b3\u30f3\u30d1\u30a4\u30eb\u3059\u308b\u3053\u3068\u3067\u3001\u30d3\u30eb\u30c9\u6642\u9593\u3092\u77ed\u7e2e\u3057\u307e\u3059\u3002<\/p>\n<p>\u305d\u3057\u3066\u3001configure_file\u3067\u51fa\u529b\u3057\u305f\u30c6\u30ad\u30b9\u30c8\u30fb\u30d5\u30a1\u30a4\u30eb\u3092\u30b3\u30f3\u30d1\u30a4\u30eb\u3059\u308b\u3088\u3046\u306a\u4f7f\u3044\u65b9\u3092\u3059\u308b\u3053\u3068\u304c\u591a\u3044\u3067\u3059\u3002\u3064\u307e\u308a\u3001\u5909\u5316\u304c\u306a\u3044\u6642\u306b\u6700\u7d42\u66f4\u65b0\u65e5\u6642\u304c\u66f4\u65b0\u3055\u308c\u306a\u3051\u308c\u3070\u7121\u99c4\u306a\u30b3\u30f3\u30d1\u30a4\u30eb\u304c\u7701\u7565\u3055\u308c\u307e\u3059\u3002<br \/>\n\u5730\u5473\u3067\u3059\u304c\u3001\u975e\u5e38\u306b\u3042\u308a\u304c\u305f\u3044\u4ed5\u69d8\u3067\u3059\u3002\uff08\u3053\u308c\u304c\u306a\u304b\u3063\u305f\u3089\u3001\u4e0b\u624b\u3059\u308b\u3068\u6bce\u56de\u30d5\u30eb\u30b3\u30f3\u30d1\u30a4\u30eb\u306b\u306a\u308a\u307e\u3059\u3002\uff09<\/p>\n<h3>\uff13\uff0e\u30b5\u30f3\u30d7\u30eb<\/h3>\n<p>Makefile\u751f\u6210\u30e2\u30fc\u30c9\u3067\u306e\u4f7f\u7528\u4f8b\u3092\u793a\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"brush: plain; title: sample.cpp.in; notranslate\" title=\"sample.cpp.in\">\r\n#include &lt;iostream&gt;\r\n\r\n#define APP_NAME\t&quot;@APP_NAME@&quot;\r\n#define VERSION_NO\t&quot;${APP_VERSION}&quot;\r\n#define\tDUMMY\t\t&quot;${DUMMY}&quot;\r\n\r\nint main()\r\n{\r\n    std::cout &lt;&lt; APP_NAME &quot; ver.&quot; VERSION_NO &lt;&lt; &quot;\\n&quot;;\r\n    std::cout &lt;&lt; &quot;@STRING@&quot; &lt;&lt; &quot;\\n&quot;;\r\n}\r\n<\/pre>\n<pre class=\"brush: plain; highlight: [14,15]; title: CMakeLists.txt; notranslate\" title=\"CMakeLists.txt\">\r\ncmake_minimum_required(VERSION 3.5.1)\r\nproject(sample)\r\n\r\nif(MSVC)\r\n    set(CMAKE_CXX_FLAGS &quot;${CMAKE_CXX_FLAGS} \/W4 \/EHsc&quot;)\r\nelse()\r\n    set(CMAKE_CXX_FLAGS &quot;${CMAKE_CXX_FLAGS} -Wall -std=c++11&quot;)\r\nendif()\r\n\r\nset(APP_NAME    &quot;SampleApplication&quot;)\r\nset(APP_VERSION &quot;1.0.0&quot;)\r\nunset(DUMMY)\r\n\r\nconfigure_file(sample.cpp.in sample1.cpp NEWLINE_STYLE LF)\r\nconfigure_file(sample.cpp.in sample2.cpp @ONLY)\r\n\r\nadd_executable(sample1 sample1.cpp)\r\nadd_executable(sample2 sample2.cpp)\r\n<\/pre>\n<p>ubuntu\u306e\u65b9\u306f\u300cNEWLINE_STYLE CRLF\u300d\u3092\u6307\u5b9a\u3057\u3066\u307f\u3066\u4e0b\u3055\u3044\u3002<\/p>\n<pre class=\"brush: plain; title: \u30d3\u30eb\u30c9\u624b\u9806; notranslate\" title=\"\u30d3\u30eb\u30c9\u624b\u9806\">\r\n&gt; mkdir build\r\n&gt; cd build\r\n&gt; cmake ..\r\n&gt; cmake --build . --config Release\r\n<\/pre>\n<pre class=\"brush: plain; title: sample1.cpp; notranslate\" title=\"sample1.cpp\">\r\n#define APP_NAME\t&quot;SampleApplication&quot;\r\n#define VERSION_NO\t&quot;1.0.0&quot;\r\n#define\tDUMMY\t\t&quot;&quot;\r\n<\/pre>\n<p>Make\u751f\u6210\u30e2\u30fc\u30c9\u306e\u6642\u3001configure_file()\u306f\u30d3\u30eb\u30c9\u30fb\u30d5\u30a9\u30eb\u30c0\uff08\u4e0a\u8a18\u306e\u5834\u5408\u306f build \uff09\u3078\u30c6\u30ad\u30b9\u30c8\u30fb\u30d5\u30a1\u30a4\u30eb\u3092\u51fa\u529b\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"brush: plain; title: buld\/sample1.cpp; notranslate\" title=\"buld\/sample1.cpp\">\r\n#include &lt;iostream&gt;\r\n\r\n#define APP_NAME    &quot;SampleApplication&quot;\r\n#define VERSION_NO  &quot;1.0.0&quot;\r\n#define DUMMY       &quot;&quot;\r\n\r\nint main()\r\n{\r\n    std::cout &lt;&lt; APP_NAME &quot; ver.&quot; VERSION_NO &lt;&lt; &quot;\\n&quot;;\r\n    std::cout &lt;&lt; &quot;&quot; &lt;&lt; &quot;\\n&quot;;\r\n}\r\n<\/pre>\n<p>\u3053\u3053\u3067\u306f\u5206\u304b\u308a\u307e\u305b\u3093\u304c\u3001sample1.cpp\u306e\u6539\u884c\u30b3\u30fc\u30c9\u306f\u3001LF \u306b\u306a\u3063\u3066\u3044\u307e\u3059\u3002\u6700\u8fd1\u306eWindows 10\u306e\u30e1\u30e2\u5e33\u306f\u6539\u884c\u30b3\u30fc\u30c9\u304cLF\u306a\u3089\u3070\u305d\u306e\u65e8\u3092\u8868\u793a\u3057\u3066\u304f\u308c\u307e\u3059\u306e\u3067\u3001\u30e1\u30e2\u5e33\u3067\u898b\u308b\u3053\u3068\u3082\u3067\u304d\u307e\u3059\u3002<br \/>\n<a href=\"https:\/\/theolizer.com\/wordpress\/wp-content\/uploads\/2019\/08\/eb6f5cf047b7c6cff5f78a904f2d7c80.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/theolizer.com\/wordpress\/wp-content\/uploads\/2019\/08\/eb6f5cf047b7c6cff5f78a904f2d7c80-100x57.png\" alt=\"\" width=\"100\" height=\"57\" class=\"alignleft size-thumbnail wp-image-6340\" srcset=\"https:\/\/theolizer.com\/wordpress\/wp-content\/uploads\/2019\/08\/eb6f5cf047b7c6cff5f78a904f2d7c80-100x57.png 100w, https:\/\/theolizer.com\/wordpress\/wp-content\/uploads\/2019\/08\/eb6f5cf047b7c6cff5f78a904f2d7c80-300x170.png 300w, https:\/\/theolizer.com\/wordpress\/wp-content\/uploads\/2019\/08\/eb6f5cf047b7c6cff5f78a904f2d7c80.png 518w\" sizes=\"auto, (max-width: 100px) 100vw, 100px\" \/><\/a><\/p>\n<pre class=\"brush: plain; title: buld\/sample2.cpp; notranslate\" title=\"buld\/sample2.cpp\">\r\n#include &lt;iostream&gt;\r\n\r\n#define APP_NAME    &quot;SampleApplication&quot;\r\n#define VERSION_NO  &quot;${APP_VERSION}&quot;\r\n#define DUMMY       &quot;${DUMMY}&quot;\r\n\r\nint main()\r\n{\r\n    std::cout &lt;&lt; APP_NAME &quot; ver.&quot; VERSION_NO &lt;&lt; &quot;\\n&quot;;\r\n    std::cout &lt;&lt; &quot;&quot; &lt;&lt; &quot;\\n&quot;;\r\n}\r\n<\/pre>\n<h3>\uff14\uff0e\u307e\u3068\u3081<\/h3>\n<p>configure_file\u306f\u3001\u4ee5\u4e0a\u306e\u3088\u3046\u306a\u7c21\u5358\u306a\u6a5f\u80fd\u3092\u63d0\u4f9b\u3059\u308b\u3060\u3051\u306e\u30b3\u30de\u30f3\u30c9\u3067\u3059\u304c\u3001\u3053\u308c\u304c\u5b9f\u306b\u91cd\u5b9d\u3057\u307e\u3059\u3002<br \/>\n\u4f8b\u3048\u3070\u3001\u30d0\u30fc\u30b8\u30e7\u30f3\u756a\u53f7\u306f\u30a2\u30d7\u30ea\u672c\u4f53\u306eexe\u3068\u30a4\u30f3\u30b9\u30c8\u30fc\u30e9\u306e\u4e21\u65b9\u306b\u540c\u3058\u3082\u306e\u3092\u53cd\u6620\u3057\u305f\u3044\u3067\u3059\u3002\u30a4\u30f3\u30b9\u30c8\u30fc\u30e9\u958b\u767a\u304cC++\u306e\u300c#define\u300d\u3084\u300cstatic const char* kVersion=&#8221;xxxx&#8221;;\u300d\u306a\u3069\u3092\u89e3\u91c8\u3067\u304d\u308b\u3053\u3068\u306f\u307e\u305a\u7121\u3044\u306e\u3067\u3001\u7570\u306a\u308b\u66f8\u5f0f\u3067\u6307\u5b9a\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002<br \/>\n\u305d\u306e\u3088\u3046\u306a\u6642\u3001CMakeLists.txt\u7b49\u3067VERSION_NO\u5909\u6570\u3092\u8a2d\u5b9a\u3057\u3066\u304a\u304d\u3001\u305d\u308c\u304b\u3089C++\u30d8\u30c3\u30c0\u3068\u30a4\u30f3\u30b9\u30c8\u30fc\u30e9\u958b\u767a\u30c4\u30fc\u30eb\u306e\u8a2d\u5b9a\u30d5\u30a1\u30a4\u30eb\u3092\u751f\u6210\u3059\u308b\u3053\u3068\u3067\u53cd\u6620\u6f0f\u308c\u304c\u5931\u304f\u306a\u308a\u307e\u3059\u3002<br \/>\n\u306a\u304b\u306a\u304b\u3042\u308a\u304c\u305f\u3044\u30b3\u30de\u30f3\u30c9\u306a\u306e\u3067\u3059\u3002<\/p>\n<p>\u3055\u3066\u3001\u6614\u306f\u6c17\u6e29\u304c30\u5ea6\u3092\u8d85\u3048\u308b\u65e5\u306a\u3093\u3066\u307b\u3068\u3093\u3069\u306a\u304b\u3063\u305f\u3068\u601d\u3046\u306e\u3067\u3059\u304c\u3001\u6700\u8fd1\u306f30\u5ea6\u3069\u3053\u308d\u304b\u4f53\u6e29\u3092\u8d85\u3048\u308b\u6c17\u6e29\u304c\u65e5\u5e38\u8336\u98ef\u4e8b\u3067\u3059\u3002\u307f\u306a\u3055\u3093\u3082\u71b1\u4e2d\u75c7\u306b\u306f\u6c17\u3092\u3064\u3051\u3066\u3001\u3053\u306e\u6691\u3044\u590f\u3092\u4e57\u308a\u5207\u3063\u3066\u4e0b\u3055\u3044\u3002<br \/>\n\u305d\u308c\u3067\u306f\u4eca\u56de\u306f\u3053\u3053\u3067\u7d42\u308f\u308a\u307e\u3059\u3002\u304a\u75b2\u308c\u69d8\u3067\u3057\u305f\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"\u3053\u3093\u306b\u3061\u306f\u3002\u7530\u539f\u3067\u3059\u3002 \u4eca\u5e74\u3082\u3044\u3088\u3044\u3088\u672c\u683c\u7684\u306a\u590f\u304c\u6765\u307e\u3057\u305f\u306d\u3002\u3044\u3084\u3001\u672c\u5f53\u306b\u6691\u3044\u3067\u3059\u3002 \u3055\u3066\u3001\u4eca\u56de\u306f\u304a\u624b\u8efd\u306b\u30c6\u30ad\u30b9\u30c8\u30fb\u30d5\u30a1\u30a4\u30eb\u3092\u52a0\u5de5\u3067\u304d\u308bconfigure_file\u30b3\u30de\u30f3\u30c9\u306b\u3064\u3044\u3066\u8aac\u660e\u3057\u307e\u3059\u3002\u30d0\u30a4\u30ca\u30ea\u306e\u30d5\u30a1\u30a4\u30eb\u540d\u3084\u30d0\u30fc\u30b8 &#8230;","protected":false},"author":5,"featured_media":6332,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[23],"tags":[],"class_list":["post-6328","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-cpp-school3"],"aioseo_notices":[],"jetpack_featured_media_url":"https:\/\/theolizer.com\/wordpress\/wp-content\/uploads\/2019\/08\/school3-11.jpg","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/theolizer.com\/wp-json\/wp\/v2\/posts\/6328","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/theolizer.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/theolizer.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/theolizer.com\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/theolizer.com\/wp-json\/wp\/v2\/comments?post=6328"}],"version-history":[{"count":0,"href":"https:\/\/theolizer.com\/wp-json\/wp\/v2\/posts\/6328\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/theolizer.com\/wp-json\/wp\/v2\/media\/6332"}],"wp:attachment":[{"href":"https:\/\/theolizer.com\/wp-json\/wp\/v2\/media?parent=6328"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/theolizer.com\/wp-json\/wp\/v2\/categories?post=6328"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/theolizer.com\/wp-json\/wp\/v2\/tags?post=6328"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}