-
Notifications
You must be signed in to change notification settings - Fork 63
Elliottc/cmake support #164
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
45 commits
Select commit
Hold shift + click to select a range
44cc597
Removed unused parameter.
ocielliottc e6d869b
Initial commit of experimental support of CMake.
ocielliottc b3dbad5
Added dynamicflags, staticflags, libpaths, and macros. Corrected bas…
ocielliottc 5099bdb
Added hard-coded configurations for libraries.
ocielliottc 56c19e2
Turn off automatic output for all custom commands. That must be hand…
ocielliottc b1c558f
Added a 'type' to the combined custom command structure.
ocielliottc 52a0110
Sort the types to ensure that the combined custom type name will be t…
ocielliottc fbd413b
Added configurable build configurations and used combined_custom to s…
ocielliottc 544dccd
Added support for flag_overrides of command flags.
ocielliottc 6540787
Use env_includes to issue the find_package() function, as it will not…
ocielliottc b6778ba
Temporarily escape new-line characters when creating an array so that…
ocielliottc a106fb8
Force CMake projects to be generated as if the user provided -use_env…
ocielliottc a69870a
Added a pre_find_target template variable and usage of compile_option…
ocielliottc caca0a0
Added support for precompiled headers.
ocielliottc c27c961
Added a workspace of sorts to handle multiple projects.
ocielliottc 52bfb94
Added settings to make CMake build things in the default style of MPC.
ocielliottc 9c4de45
Check for dynamicflags and staticflags before using them. Added pch_…
ocielliottc 9b2f574
Added a language to the workspace project.
ocielliottc 2d743f8
Insert subdirectories after all find_package() calls to allow for con…
ocielliottc 6f8a50e
Sort combined commands (based on original type) so that projects are …
ocielliottc 3812eb0
Process escaped characters within forfirst, forlast, fornotfirst, for…
ocielliottc 75f1165
Initial modifications to support switching between shared and static …
ocielliottc f93e568
Moved the configurable library decorator into the project target name…
ocielliottc 65a3e3a
Replaced hard-coded calls to find_package() with "packages" template …
ocielliottc df6fab3
Added information on CMake support.
ocielliottc 3b31153
Change target_include_directories and target_link_directories to be P…
ocielliottc 3e14ac8
Set the target link libraries to the libraries specified without any …
ocielliottc 4835d3d
Corrected the warning message.
ocielliottc 6661408
No need to output archive, library, or runtime output directory setti…
ocielliottc 4bb959f
Fixed the translation of "." when used within libpaths.
ocielliottc a2195d2
Modified the template to incorporate the project name into variables.
ocielliottc 38aa629
Use the workspace name in the workspace CMakeLists.txt and repaced al…
ocielliottc c4e2b6a
Define MPC_LIB_MODIFIER as ACE expects it to be defined.
ocielliottc a91abb9
Added a comment about the dollar sign.
ocielliottc 803712a
Merge branch 'master' into elliottc/cmake-support
ocielliottc 3755fb8
Added a missing space.
ocielliottc 4339fa3
Add CMake style references.
ocielliottc fe21794
Use the macro for the XercesC to allow generation of CMakeLists that …
ocielliottc 1d04f70
Added a template function to help determine if a variable value is a …
ocielliottc f6915f5
Corrected problems with generation of CMake workspaces with directori…
ocielliottc d4736ff
Handle out-of-tree directories properly by creating a workspace for e…
ocielliottc 841f148
Support multiple projects in the out-of-tree workspaces.
ocielliottc a486539
Added headers, inline files, and template files as variables to allow…
ocielliottc a14caf1
Make dynamicflags and staticflags PRIVATE so that they are not propag…
ocielliottc 26e3b92
Switch from converting $() vars to non-environment variables. Allow …
ocielliottc File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 $ 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 $() values converted to $ENV{}. | ||
ocielliottc marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| env_exeout = The value of 'exeout' with $() values converted to $ENV{}. | ||
| env_includes = The value of 'includes' with $() values converted to $ENV{}. | ||
| env_libout = The value of 'libout' with $() values converted to $ENV{}. | ||
| env_libpaths = The value of 'libpaths' with $() values converted to $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. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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...
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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_packagemultiple times? Does it ignore the additional ones?There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that's the typical pattern, for them to be in the top level CMakeLists or something that file includes.
I don't think there's an explicit
OPTIONALargument, only an explicitREQUIRED. 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.