Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
44cc597
Removed unused parameter.
ocielliottc Oct 10, 2022
e6d869b
Initial commit of experimental support of CMake.
ocielliottc Oct 10, 2022
b3dbad5
Added dynamicflags, staticflags, libpaths, and macros. Corrected bas…
ocielliottc Oct 11, 2022
5099bdb
Added hard-coded configurations for libraries.
ocielliottc Oct 11, 2022
56c19e2
Turn off automatic output for all custom commands. That must be hand…
ocielliottc Oct 12, 2022
b1c558f
Added a 'type' to the combined custom command structure.
ocielliottc Oct 12, 2022
52a0110
Sort the types to ensure that the combined custom type name will be t…
ocielliottc Oct 12, 2022
fbd413b
Added configurable build configurations and used combined_custom to s…
ocielliottc Oct 12, 2022
544dccd
Added support for flag_overrides of command flags.
ocielliottc Oct 12, 2022
6540787
Use env_includes to issue the find_package() function, as it will not…
ocielliottc Oct 13, 2022
b6778ba
Temporarily escape new-line characters when creating an array so that…
ocielliottc Oct 14, 2022
a106fb8
Force CMake projects to be generated as if the user provided -use_env…
ocielliottc Oct 14, 2022
a69870a
Added a pre_find_target template variable and usage of compile_option…
ocielliottc Oct 14, 2022
caca0a0
Added support for precompiled headers.
ocielliottc Oct 17, 2022
c27c961
Added a workspace of sorts to handle multiple projects.
ocielliottc Oct 17, 2022
52bfb94
Added settings to make CMake build things in the default style of MPC.
ocielliottc Oct 18, 2022
9c4de45
Check for dynamicflags and staticflags before using them. Added pch_…
ocielliottc Oct 19, 2022
9b2f574
Added a language to the workspace project.
ocielliottc Oct 19, 2022
2d743f8
Insert subdirectories after all find_package() calls to allow for con…
ocielliottc Oct 20, 2022
6f8a50e
Sort combined commands (based on original type) so that projects are …
ocielliottc Oct 21, 2022
3812eb0
Process escaped characters within forfirst, forlast, fornotfirst, for…
ocielliottc Oct 21, 2022
75f1165
Initial modifications to support switching between shared and static …
ocielliottc Oct 25, 2022
f93e568
Moved the configurable library decorator into the project target name…
ocielliottc Oct 25, 2022
65a3e3a
Replaced hard-coded calls to find_package() with "packages" template …
ocielliottc Oct 26, 2022
df6fab3
Added information on CMake support.
ocielliottc Oct 26, 2022
3b31153
Change target_include_directories and target_link_directories to be P…
ocielliottc Oct 31, 2022
3e14ac8
Set the target link libraries to the libraries specified without any …
ocielliottc Oct 31, 2022
4835d3d
Corrected the warning message.
ocielliottc Nov 1, 2022
6661408
No need to output archive, library, or runtime output directory setti…
ocielliottc Nov 4, 2022
4bb959f
Fixed the translation of "." when used within libpaths.
ocielliottc Nov 4, 2022
a2195d2
Modified the template to incorporate the project name into variables.
ocielliottc Nov 7, 2022
38aa629
Use the workspace name in the workspace CMakeLists.txt and repaced al…
ocielliottc Nov 9, 2022
c4e2b6a
Define MPC_LIB_MODIFIER as ACE expects it to be defined.
ocielliottc Nov 10, 2022
a91abb9
Added a comment about the dollar sign.
ocielliottc Nov 10, 2022
803712a
Merge branch 'master' into elliottc/cmake-support
ocielliottc Nov 11, 2022
3755fb8
Added a missing space.
ocielliottc Nov 11, 2022
4339fa3
Add CMake style references.
ocielliottc Nov 11, 2022
fe21794
Use the macro for the XercesC to allow generation of CMakeLists that …
ocielliottc Nov 15, 2022
1d04f70
Added a template function to help determine if a variable value is a …
ocielliottc Nov 15, 2022
f6915f5
Corrected problems with generation of CMake workspaces with directori…
ocielliottc Nov 17, 2022
d4736ff
Handle out-of-tree directories properly by creating a workspace for e…
ocielliottc Nov 17, 2022
841f148
Support multiple projects in the out-of-tree workspaces.
ocielliottc Nov 17, 2022
a486539
Added headers, inline files, and template files as variables to allow…
ocielliottc Nov 21, 2022
a14caf1
Make dynamicflags and staticflags PRIVATE so that they are not propag…
ocielliottc Nov 22, 2022
26e3b92
Switch from converting $() vars to non-environment variables. Allow …
ocielliottc Nov 23, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions config/openssl.mpb
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@ feature(openssl) {
$(SSL_ROOT)/lib
}

includes += $(SSL_INCDIR)
libpaths += $(SSL_LIBDIR)
specific(!cmake) {
includes += $(SSL_INCDIR)
libpaths += $(SSL_LIBDIR)
}

specific(prop:windows) {
lit_libs += libeay32 ssleay32
Expand All @@ -36,6 +38,15 @@ feature(openssl) {
specific(prop:microsoft) {
libpaths += $(SSL_ROOT)/lib/VC
}

specific(cmake) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if this did something like...

verbatim(cmake, foo, 1) {
  find_package(OpenSSL)
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It could. But, I think the problem there is that if you want to build your code without OpenSSL, the find_package() would cause cmake to choke (assuming it wasn't available). I am expecting things like that to be done at a higher level than the project level.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's an option of find_package(OpenSSL REQUIRED) -- not sure how that would be represented (if we wanted to), maybe it would relate to MPC features.

I don't mind leaving it out. Just curious if it was easy to automate some of this... I wonder what happens if CMake sees the same find_package multiple times? Does it ignore the additional ones?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you mean OPTIONAL? Anyway, if it's there, having the valued for includes and libraries could cause a problem if the user is using something else to control whether OpenSSL is used or not.

It does appear to ignore duplicated find_package() calls.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am expecting things like that to be done at a higher level than the project level.

Yes, that's the typical pattern, for them to be in the top level CMakeLists or something that file includes.

Did you mean OPTIONAL? Anyway, if it's there, having the valued for includes and libraries could cause a problem if the user is using something else to control whether OpenSSL is used or not.
It does appear to ignore duplicated find_package() calls.

I don't think there's an explicit OPTIONAL argument, only an explicit REQUIRED. Also, yes additional calls should be ignored, but it's up to the package. I know ours used to throw a fatal error if called multiple times. Things that are builtin like OpenSSL should be safe though if we're not trying to force something that's different than what was declared before.

// Undo the else of the !prop:windows above.
lit_libs -= ssl crypto
includes -= /usr/kerberos/include

lit_libs += ${OPENSSL_LIBRARIES}
includes += ${OPENSSL_INCLUDE_DIR}
}
}

feature(openssl11) {
Expand Down
11 changes: 8 additions & 3 deletions config/xerces.mpb
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,6 @@ feature(xerces3) {
$(XERCESCROOT)/lib
}

includes += $(XERCESC_INCDIR)
libpaths += $(XERCESC_LIBDIR)

specific(prop:microsoft) {
xerceslib = xerces-c_3

Expand All @@ -57,6 +54,14 @@ feature(xerces3) {
xerceslib = xerces-c
}

specific(cmake) {
includes += ${XercesC_INCLUDE_DIRS}
xerceslib = ${XercesC_LIBRARIES}
} else {
includes += $(XERCESC_INCDIR)
libpaths += $(XERCESC_LIBDIR)
}

// We have to use lit_libs here as the library decorator
// does not necessarily match what MPC uses (particularly for
// static builds).
Expand Down
8 changes: 4 additions & 4 deletions docs/USAGE
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ Usage: mwc.pl [-global <file>] [-include <directory>] [-recurse]
[-workers <#>] [-workers_dir <dir> | -workers_port <#>]
[-language <cplusplus | csharp | java | vb>]
[-type <automake | bcb2007 | bcb2009 | bds4 | bmake | cc | cdt6 |
cdt7 | em3 | ghs | html | iar | make | nmake | rpmspec |
sle | uvis | vc6 | vc7 | vc71 | vc8 | vc9 | vc10 | vc11 |
vc12 | vc14 | vs2017 | vs2019 | vs2022 | wb26 | wb30 |
wix>]
cdt7 | cmake | em3 | ghs | html | iar | make | nmake |
rpmspec | sle | uvis | vc6 | vc7 | vc8 | vc9 | vc10 |
vc11 | vc12 | vc14 | vc71 | vs2017 | vs2019 | vs2022 |
wb26 | wb30 | wix>]
[files]

-base Add <project> as a base project to each generated
Expand Down
45 changes: 42 additions & 3 deletions docs/html/MakeProjectCreator.html
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,18 @@ <h6 class="NumberedTableTitle">MPC Types</h6>
</td>
</tr>

<tr>
<td rowspan="1" colspan="1">
<p class="Tbl-Body">
<em class="TableCode">cmake</em>
</p>
</td>

<td rowspan="1" colspan="1">
<p class="Tbl-Body">Support for CMake requires user provided modules for custom commands.</p>
</td>
</tr>

<tr>
<td rowspan="1" colspan="1">
<p class="Tbl-Body">
Expand Down Expand Up @@ -6782,7 +6794,7 @@ <h5 class="Head4">Example MPC File</h5>
</blockquote>

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

<blockquote>
Expand Down Expand Up @@ -8174,7 +8188,7 @@ <h6 class="Head5">

<blockquote>

<p class="Code">document_template.pl v1.3</p>
<p class="Code">document_template.pl v1.4</p>

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

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

<p class="Code">
template &nbsp;&nbsp;&nbsp;- .mpd file to document. Certain MPC types don't
use a template,
</p>

<p class="Code">
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;in that case this aregument can be the Perl module.
</p>

<p class="Code">
html output - This defaults to the name of the
template file with the .mpd
Expand Down Expand Up @@ -8558,6 +8582,21 @@ <h6 class="NumberedTableTitle">
</td>
</tr>

<tr>
<td rowspan="1" colspan="1">
<p class="Tbl-Body">
<em class=
"TableCode">command-&gt;type</em>
</p>
</td>

<td rowspan="1" colspan="1">
<p class="Tbl-Body">
The original type of file for this command.
</p>
</td>
</tr>

</table>
</p>

Expand Down
17 changes: 17 additions & 0 deletions docs/templates/cmake.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// Current as of 10/26/2022
// This defines the role of all the template variables specific to the
// 'cmake' project type.
//
// The value &#36; is used below to represent the dollar sign. The dollar
// sign is interpreted by the parser in document_template.pl.
//
// Please try to keep this alphabetically sorted.
//
cmake_minimum_required = Sets the minimum required version for CMake.
env_dllout = The value of 'dllout' with &#36;() values converted to &#36;ENV{}.
env_exeout = The value of 'exeout' with &#36;() values converted to &#36;ENV{}.
env_includes = The value of 'includes' with &#36;() values converted to &#36;ENV{}.
env_libout = The value of 'libout' with &#36;() values converted to &#36;ENV{}.
env_libpaths = The value of 'libpaths' with &#36;() values converted to &#36;ENV{}.
packages = A list of packages to be used with the find_package() command.
pre_find_package = A specific command or set of commands to be issued before any find_package() commands are called.
117 changes: 117 additions & 0 deletions modules/CMakeProjectCreator.pm
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
package CMakeProjectCreator;

# ************************************************************
# Description : A CMake Project Creator
# Author : Chad Elliott
# Create Date : 10/10/2022
# ************************************************************

# ************************************************************
# Pragmas
# ************************************************************

use strict;

use ProjectCreator;

use vars qw(@ISA);
@ISA = qw(ProjectCreator);

# ************************************************************
# Subroutine Section
# ************************************************************

sub pre_generation {
my $self = shift;

## For CMake, we are expecting a hybrid of custom types and modules.
## We are turning off all automatic output so that the modules defined
## for CMake can handle these artifacts.
foreach my $gentype (keys %{$self->{'generated_exts'}}) {
$self->{'generated_exts'}->{$gentype}->{'automatic_out'} = 0;
}
}

sub default_to_library {
## In case there are only generated source files...
return 1;
}

sub need_to_write_project {
my $self = shift;

## Because we do not automatically add custom output, it is possible that
## the project only has generated source files and expects them to cause
## an automatic library name to be chosen. If the base
## need_to_write_project() tells us that it's only generated source files
## but the user didn't mark this project as "custom only", then we have to
## override it back to 1 to retain the user provided target name.
my $status = $self->SUPER::need_to_write_project();
if ($status == 2 && !$self->get_assignment('custom_only')) {
$status = 1;
}

return $status;
}

sub get_use_env {
## Override the option getter so that, for CMake, MPC always functions as
## if the -use_env option was supplied on the command line.
return 1;
}

sub pre_write_output_file {
my $self = shift;
return $self->combine_custom_types();
}

sub dollar_special {
return 1;
}

sub project_file_prefix {
return "CMakeLists.";
}

sub escape_spaces {
#my $self = shift;
return 1;
}

sub get_dll_exe_template_input_file {
return 'cmakeexe';
}

sub get_dll_template_input_file {
return 'cmakedll';
}

sub fill_value {
my($self, $name) = @_;

if ($name eq 'language') {
## Currently, we only support C++
return 'CXX' if ($self->get_language() eq Creator::cplusplus());
}
elsif ($name =~ /^env_(\w+)/) {
my $dotdir = '${CMAKE_CURRENT_SOURCE_DIR}' .
($1 eq 'libpaths' ? ' ${CMAKE_CURRENT_BINARY_DIR}' : '');
my $paths = $self->get_assignment($1);
if (defined $paths) {
$paths = $self->create_array($paths);
foreach my $path (@$paths) {
if ($path eq '.') {
$path = $dotdir;
}
else {
$path =~ s/\$\(([^\)]+)\)/\${$1}/g;
}
}
return "@$paths";
}
}

return undef;
}

1;
Loading