@@ -541,6 +541,35 @@ void generate_cmake(const char *path, const parser::Project *parent_project) {
541541 ss << " \" )\n\n " ;
542542 }
543543
544+ if (!project.options .empty ()) {
545+ comment (" Options" );
546+ for (const auto &opt : project.options ) {
547+ cmd (" option" )(opt.name , opt.comment , opt.val ? " ON" : " OFF" );
548+ }
549+ endl ();
550+ }
551+
552+ if (!project.settings .empty ()) {
553+ comment (" Settings" );
554+ for (const auto &set : project.settings ) {
555+ std::string set_val;
556+ if (set.val .index () == 1 ) {
557+ set_val = mpark::get<1 >(set.val );
558+ } else {
559+ set_val = mpark::get<0 >(set.val ) ? " ON" : " OFF" ;
560+ }
561+
562+ if (set.cache ) {
563+ auto typ = set.val .index () == 1 ? " STRING" : " BOOL" ;
564+ auto force = set.force ? " FORCE" : " " ;
565+ cmd (" set" )(set.name , set_val, typ, set.comment , force);
566+ } else {
567+ cmd (" set" )(set.name , set_val);
568+ }
569+ }
570+ endl ();
571+ }
572+
544573 gen.handle_condition (project.include_before , [&](const std::string &, const std::vector<std::string> &includes) { inject_includes (includes); });
545574 gen.handle_condition (project.cmake_before , [&](const std::string &, const std::string &cmake) { inject_cmake (cmake); });
546575
@@ -673,35 +702,6 @@ void generate_cmake(const char *path, const parser::Project *parent_project) {
673702 }
674703 }
675704
676- if (!project.options .empty ()) {
677- comment (" Options" );
678- for (const auto &opt : project.options ) {
679- cmd (" option" )(opt.name , opt.comment , opt.val ? " ON" : " OFF" );
680- }
681- endl ();
682- }
683-
684- if (!project.settings .empty ()) {
685- comment (" Settings" );
686- for (const auto &set : project.settings ) {
687- std::string set_val;
688- if (set.val .index () == 1 ) {
689- set_val = mpark::get<1 >(set.val );
690- } else {
691- set_val = mpark::get<0 >(set.val ) ? " ON" : " OFF" ;
692- }
693-
694- if (set.cache ) {
695- auto typ = set.val .index () == 1 ? " STRING" : " BOOL" ;
696- auto force = set.force ? " FORCE" : " " ;
697- cmd (" set" )(set.name , set_val, typ, set.comment , force);
698- } else {
699- cmd (" set" )(set.name , set_val);
700- }
701- }
702- endl ();
703- }
704-
705705 auto add_subdir = [&](const std::string &dir) {
706706 // clang-format off
707707 comment (dir);
0 commit comments