Skip to content

Commit 41b00b4

Browse files
committed
reflect gen code in new CMakeLists.txt
1 parent b016d71 commit 41b00b4

File tree

2 files changed

+24
-8
lines changed

2 files changed

+24
-8
lines changed

CMakeLists.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# This file was generated automatically by cmkr.
22

3+
# Regenerate CMakeLists.txt file when necessary
4+
include(cmkr.cmake OPTIONAL RESULT_VARIABLE CMKR_INCLUDE_RESULT)
5+
6+
if(CMKR_INCLUDE_RESULT)
7+
cmkr()
8+
endif()
9+
310
cmake_minimum_required(VERSION 3.15)
411

512
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

src/gen.cpp

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,9 @@ int generate_cmake(const char *path) {
111111
std::stringstream ss;
112112
ss << "# This file was generated automatically by cmkr.\n";
113113
ss << "\n";
114-
114+
115115
ss << "# Regenerate CMakeLists.txt file when necessary\n";
116-
ss << "include(cmkr.cmake OPTIONAL RESULT_VARIABLE CMKR_INCLUDE_RESULT)\n";
116+
ss << "include(cmkr.cmake OPTIONAL RESULT_VARIABLE CMKR_INCLUDE_RESULT)\n\n";
117117
ss << "if(CMKR_INCLUDE_RESULT)\n";
118118
ss << "\tcmkr()\n";
119119
ss << "endif()\n";
@@ -225,14 +225,19 @@ int generate_cmake(const char *path) {
225225
} else {
226226
set_val = std::get<bool>(set.val) ? "ON" : "OFF";
227227
}
228-
ss << "set(" << set.name << " " << set_val;;
228+
ss << "set(" << set.name << " " << set_val;
229+
;
229230
if (set.cache) {
230231
std::string typ;
231-
if (set.val.index() == 1) typ = "STRING"; else typ = "BOOL";
232-
ss << " CACHE " << typ << " \"" << set.comment << "\"";
233-
if (set.force) ss << " FORCE";
232+
if (set.val.index() == 1)
233+
typ = "STRING";
234+
else
235+
typ = "BOOL";
236+
ss << " CACHE " << typ << " \"" << set.comment << "\"";
237+
if (set.force)
238+
ss << " FORCE";
234239
}
235-
ss << ")\n\n";
240+
ss << ")\n\n";
236241
}
237242
}
238243

@@ -364,7 +369,11 @@ int generate_cmake(const char *path) {
364369
ss << conf << " ";
365370
}
366371
}
367-
ss << "\n\tDESTINATION " << inst.destination << "\n\t)\n\n";
372+
ss << "\n\tDESTINATION " << inst.destination << "\n\t";
373+
if (!inst.targets.empty())
374+
ss << "COMPONENT " << inst.targets[0] << "\n\t)\n\n";
375+
else
376+
ss << "\n\t)\n\n";
368377
}
369378
}
370379

0 commit comments

Comments
 (0)