summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChad Elliott <elliottc@objectcomputing.com>2022-10-11 09:31:43 -0500
committerChad Elliott <elliottc@objectcomputing.com>2022-10-11 09:31:43 -0500
commitb3dbad5d84d83bcf809e7aba458627b6014d6d71 (patch)
tree6a2afed7bc1eb02aa19db05d73501c289c9f47b7
parente6d869bed6cacb8efae257d265bb7b97f169d8a5 (diff)
downloadMPC-b3dbad5d84d83bcf809e7aba458627b6014d6d71.tar.gz
Added dynamicflags, staticflags, libpaths, and macros. Corrected basic support for custom types.
-rw-r--r--modules/CMakeProjectCreator.pm21
-rw-r--r--templates/cmake.mpd25
2 files changed, 37 insertions, 9 deletions
diff --git a/modules/CMakeProjectCreator.pm b/modules/CMakeProjectCreator.pm
index 991a8a82..cf9883d0 100644
--- a/modules/CMakeProjectCreator.pm
+++ b/modules/CMakeProjectCreator.pm
@@ -56,14 +56,21 @@ sub fill_value {
## Currently, we only support C++
return 'CXX' if ($self->get_language() eq Creator::cplusplus());
}
- elsif ($name eq 'env_includes') {
- my $includes = $self->get_assignment('includes');
- if (defined $includes) {
- $includes = $self->create_array($includes);
- foreach my $include (@$includes) {
- $include =~ s/\$\(([^\)]+)\)/\$ENV{$1}/g;
+ elsif ($name =~ /^env_(\w+)/) {
+ my $dotdir = ($1 eq 'libpaths' ? '${CMAKE_CURRENT_BIN_DIR}' :
+ '${CMAKE_CURRENT_SOURCE_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/\$\(([^\)]+)\)/\$ENV{$1}/g;
+ }
}
- return "@$includes";
+ return "@$paths";
}
}
elsif ($name eq 'non_generated_sources') {
diff --git a/templates/cmake.mpd b/templates/cmake.mpd
index 94666a3f..ed263236 100644
--- a/templates/cmake.mpd
+++ b/templates/cmake.mpd
@@ -35,16 +35,28 @@ set(PROJECT_TARGET <%staticname%>)
<%endif%>
<%marker(macros)%>
+<%if(libout)%>
+set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY <%env_libout%>)
+<%endif%>
+<%if(dllout || libout)%>
+set(CMAKE_LIBRARY_OUTPUT_DIRECTORY <%if(dllout)%><%env_dllout%><%else%><%env_libout%><%endif%>)
+<%endif%>
+<%if(exeout)%>
+set(CMAKE_RUNTIME_OUTPUT_DIRECTORY <%env_exeout%>)
+<%endif%>
+
<%if(exename)%>
add_executable(${PROJECT_TARGET} ${SOURCE_FILES})
target_link_libraries(${PROJECT_TARGET} ${TARGET_LINK_LIBRARIES})
<%else%>
<%if(sharedname)%>
add_library(${PROJECT_TARGET} SHARED ${SOURCE_FILES})
+add_compile_definitions(<%dynamicflags%>)
target_link_libraries(${PROJECT_TARGET} ${TARGET_LINK_LIBRARIES})
<%else%>
<%if(staticname)%>
add_library(${PROJECT_TARGET} ${SOURCE_FILES})
+add_compile_definitions(<%staticflags%>)
<%endif%>
<%endif%>
<%endif%>
@@ -53,11 +65,20 @@ add_library(${PROJECT_TARGET} ${SOURCE_FILES})
target_include_directories(${PROJECT_TARGET} PUBLIC <%env_includes%>)
<%endif%>
+<%if(libpaths)%>
+target_link_directories(${PROJECT_TARGET} PUBLIC <%env_libpaths%>)
+
+<%endif%>
+<%if(macros)%>
+add_compile_definitions(<%macros%>)
+<%endif%>
<%if(custom_types)%>
<%foreach(custom_types)%>
<%if(custom_type->command && custom_type->input_files)%>
-include(<%custom_type%>.cmake OPTIONAL)
-<%uc(custom_type)%>_TARGET_SOURCES(${PROJECT_TARGET} PUBLIC <%custom_type->input_files%>)
+
+include(<%custom_type%> OPTIONAL)
+<%uc(custom_type)%>_TARGET_SOURCES(${PROJECT_TARGET} PUBLIC <%custom_type->input_files%>
+ <%uc(custom_type)%>_OPTIONS <%custom_type->commandflags%>)
<%endif%>
<%endfor%>
<%endif%>