Skip to content

Commit 60b0c90

Browse files
authored
Merge pull request DOCGroup#164 from DOCGroup/elliottc/cmake-support
Elliottc/cmake support
2 parents 5aad93c + 26e3b92 commit 60b0c90

16 files changed

+700
-25
lines changed

config/openssl.mpb

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,10 @@ feature(openssl) {
1313
$(SSL_ROOT)/lib
1414
}
1515

16-
includes += $(SSL_INCDIR)
17-
libpaths += $(SSL_LIBDIR)
16+
specific(!cmake) {
17+
includes += $(SSL_INCDIR)
18+
libpaths += $(SSL_LIBDIR)
19+
}
1820

1921
specific(prop:windows) {
2022
lit_libs += libeay32 ssleay32
@@ -36,6 +38,15 @@ feature(openssl) {
3638
specific(prop:microsoft) {
3739
libpaths += $(SSL_ROOT)/lib/VC
3840
}
41+
42+
specific(cmake) {
43+
// Undo the else of the !prop:windows above.
44+
lit_libs -= ssl crypto
45+
includes -= /usr/kerberos/include
46+
47+
lit_libs += ${OPENSSL_LIBRARIES}
48+
includes += ${OPENSSL_INCLUDE_DIR}
49+
}
3950
}
4051

4152
feature(openssl11) {

config/xerces.mpb

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,6 @@ feature(xerces3) {
3838
$(XERCESCROOT)/lib
3939
}
4040

41-
includes += $(XERCESC_INCDIR)
42-
libpaths += $(XERCESC_LIBDIR)
43-
4441
specific(prop:microsoft) {
4542
xerceslib = xerces-c_3
4643

@@ -57,6 +54,14 @@ feature(xerces3) {
5754
xerceslib = xerces-c
5855
}
5956

57+
specific(cmake) {
58+
includes += ${XercesC_INCLUDE_DIRS}
59+
xerceslib = ${XercesC_LIBRARIES}
60+
} else {
61+
includes += $(XERCESC_INCDIR)
62+
libpaths += $(XERCESC_LIBDIR)
63+
}
64+
6065
// We have to use lit_libs here as the library decorator
6166
// does not necessarily match what MPC uses (particularly for
6267
// static builds).

docs/USAGE

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ Usage: mwc.pl [-global <file>] [-include <directory>] [-recurse]
2424
[-workers <#>] [-workers_dir <dir> | -workers_port <#>]
2525
[-language <cplusplus | csharp | java | vb>]
2626
[-type <automake | bcb2007 | bcb2009 | bds4 | bmake | cc | cdt6 |
27-
cdt7 | em3 | ghs | html | iar | make | nmake | rpmspec |
28-
sle | uvis | vc6 | vc7 | vc71 | vc8 | vc9 | vc10 | vc11 |
29-
vc12 | vc14 | vs2017 | vs2019 | vs2022 | wb26 | wb30 |
30-
wix>]
27+
cdt7 | cmake | em3 | ghs | html | iar | make | nmake |
28+
rpmspec | sle | uvis | vc6 | vc7 | vc8 | vc9 | vc10 |
29+
vc11 | vc12 | vc14 | vc71 | vs2017 | vs2019 | vs2022 |
30+
wb26 | wb30 | wix>]
3131
[files]
3232

3333
-base Add <project> as a base project to each generated

docs/html/MakeProjectCreator.html

Lines changed: 42 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,18 @@ <h6 class="NumberedTableTitle">MPC Types</h6>
283283
</td>
284284
</tr>
285285

286+
<tr>
287+
<td rowspan="1" colspan="1">
288+
<p class="Tbl-Body">
289+
<em class="TableCode">cmake</em>
290+
</p>
291+
</td>
292+
293+
<td rowspan="1" colspan="1">
294+
<p class="Tbl-Body">Support for CMake requires user provided modules for custom commands.</p>
295+
</td>
296+
</tr>
297+
286298
<tr>
287299
<td rowspan="1" colspan="1">
288300
<p class="Tbl-Body">
@@ -6782,7 +6794,7 @@ <h5 class="Head4">Example MPC File</h5>
67826794
</blockquote>
67836795

67846796
<p class="Body">
6785-
The following mpc file (<em class=
6797+
The following .mpc file (<em class=
67866798
"Code">RTEC_Perf.mpc</em> ) shows the simple and small number of
67876799
lines required to generate usable build tool project files.
67886800
</p>
@@ -6899,7 +6911,9 @@ <h5 class="Head4">Example MPC File</h5>
68996911
Line five adds <em class=
69006912
"Code">TAO_RTEC_PERF_BUILD_DLL</em> to the <em class=
69016913
"Code">dllflags</em>, which defines a macro that is used by the
6902-
<em class="Code">rtec_perf_export.h</em> header file.
6914+
<em class="Code">rtec_perf_export.h</em> header file when
6915+
building shared libraries on platforms that support symbol
6916+
visibility.
69036917
</p>
69046918

69056919
<blockquote>
@@ -8174,7 +8188,7 @@ <h6 class="Head5">
81748188

81758189
<blockquote>
81768190

8177-
<p class="Code">document_template.pl v1.3</p>
8191+
<p class="Code">document_template.pl v1.4</p>
81788192

81798193
<p class="Code">
81808194
Usage: document_template.pl &lt;template&gt;
@@ -8183,6 +8197,16 @@ <h6 class="Head5">
81838197

81848198
<p class="Code">&nbsp;</p>
81858199

8200+
<p class="Code">
8201+
template &nbsp;&nbsp;&nbsp;- .mpd file to document. Certain MPC types don't
8202+
use a template,
8203+
</p>
8204+
8205+
<p class="Code">
8206+
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
8207+
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;in that case this aregument can be the Perl module.
8208+
</p>
8209+
81868210
<p class="Code">
81878211
html output - This defaults to the name of the
81888212
template file with the .mpd
@@ -8558,6 +8582,21 @@ <h6 class="NumberedTableTitle">
85588582
</td>
85598583
</tr>
85608584

8585+
<tr>
8586+
<td rowspan="1" colspan="1">
8587+
<p class="Tbl-Body">
8588+
<em class=
8589+
"TableCode">command-&gt;type</em>
8590+
</p>
8591+
</td>
8592+
8593+
<td rowspan="1" colspan="1">
8594+
<p class="Tbl-Body">
8595+
The original type of file for this command.
8596+
</p>
8597+
</td>
8598+
</tr>
8599+
85618600
</table>
85628601
</p>
85638602

docs/templates/cmake.txt

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Current as of 10/26/2022
2+
// This defines the role of all the template variables specific to the
3+
// 'cmake' project type.
4+
//
5+
// The value &#36; is used below to represent the dollar sign. The dollar
6+
// sign is interpreted by the parser in document_template.pl.
7+
//
8+
// Please try to keep this alphabetically sorted.
9+
//
10+
cmake_minimum_required = Sets the minimum required version for CMake.
11+
env_dllout = The value of 'dllout' with &#36;() values converted to &#36;ENV{}.
12+
env_exeout = The value of 'exeout' with &#36;() values converted to &#36;ENV{}.
13+
env_includes = The value of 'includes' with &#36;() values converted to &#36;ENV{}.
14+
env_libout = The value of 'libout' with &#36;() values converted to &#36;ENV{}.
15+
env_libpaths = The value of 'libpaths' with &#36;() values converted to &#36;ENV{}.
16+
packages = A list of packages to be used with the find_package() command.
17+
pre_find_package = A specific command or set of commands to be issued before any find_package() commands are called.

modules/CMakeProjectCreator.pm

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
package CMakeProjectCreator;
2+
3+
# ************************************************************
4+
# Description : A CMake Project Creator
5+
# Author : Chad Elliott
6+
# Create Date : 10/10/2022
7+
# ************************************************************
8+
9+
# ************************************************************
10+
# Pragmas
11+
# ************************************************************
12+
13+
use strict;
14+
15+
use ProjectCreator;
16+
17+
use vars qw(@ISA);
18+
@ISA = qw(ProjectCreator);
19+
20+
# ************************************************************
21+
# Subroutine Section
22+
# ************************************************************
23+
24+
sub pre_generation {
25+
my $self = shift;
26+
27+
## For CMake, we are expecting a hybrid of custom types and modules.
28+
## We are turning off all automatic output so that the modules defined
29+
## for CMake can handle these artifacts.
30+
foreach my $gentype (keys %{$self->{'generated_exts'}}) {
31+
$self->{'generated_exts'}->{$gentype}->{'automatic_out'} = 0;
32+
}
33+
}
34+
35+
sub default_to_library {
36+
## In case there are only generated source files...
37+
return 1;
38+
}
39+
40+
sub need_to_write_project {
41+
my $self = shift;
42+
43+
## Because we do not automatically add custom output, it is possible that
44+
## the project only has generated source files and expects them to cause
45+
## an automatic library name to be chosen. If the base
46+
## need_to_write_project() tells us that it's only generated source files
47+
## but the user didn't mark this project as "custom only", then we have to
48+
## override it back to 1 to retain the user provided target name.
49+
my $status = $self->SUPER::need_to_write_project();
50+
if ($status == 2 && !$self->get_assignment('custom_only')) {
51+
$status = 1;
52+
}
53+
54+
return $status;
55+
}
56+
57+
sub get_use_env {
58+
## Override the option getter so that, for CMake, MPC always functions as
59+
## if the -use_env option was supplied on the command line.
60+
return 1;
61+
}
62+
63+
sub pre_write_output_file {
64+
my $self = shift;
65+
return $self->combine_custom_types();
66+
}
67+
68+
sub dollar_special {
69+
return 1;
70+
}
71+
72+
sub project_file_prefix {
73+
return "CMakeLists.";
74+
}
75+
76+
sub escape_spaces {
77+
#my $self = shift;
78+
return 1;
79+
}
80+
81+
sub get_dll_exe_template_input_file {
82+
return 'cmakeexe';
83+
}
84+
85+
sub get_dll_template_input_file {
86+
return 'cmakedll';
87+
}
88+
89+
sub fill_value {
90+
my($self, $name) = @_;
91+
92+
if ($name eq 'language') {
93+
## Currently, we only support C++
94+
return 'CXX' if ($self->get_language() eq Creator::cplusplus());
95+
}
96+
elsif ($name =~ /^env_(\w+)/) {
97+
my $dotdir = '${CMAKE_CURRENT_SOURCE_DIR}' .
98+
($1 eq 'libpaths' ? ' ${CMAKE_CURRENT_BINARY_DIR}' : '');
99+
my $paths = $self->get_assignment($1);
100+
if (defined $paths) {
101+
$paths = $self->create_array($paths);
102+
foreach my $path (@$paths) {
103+
if ($path eq '.') {
104+
$path = $dotdir;
105+
}
106+
else {
107+
$path =~ s/\$\(([^\)]+)\)/\${$1}/g;
108+
}
109+
}
110+
return "@$paths";
111+
}
112+
}
113+
114+
return undef;
115+
}
116+
117+
1;

0 commit comments

Comments
 (0)