Commit f433fd0c authored by Malte Heithoff's avatar Malte Heithoff
Browse files

ModuleDependency as find_package

parent 81e57ba5
Pipeline #357772 passed with stage
in 14 minutes and 23 seconds
......@@ -56,8 +56,6 @@ public class CMakeConfig {
private List<String> cmakeLibraryLinkageList = new ArrayList<>();
private List<String> cmakeFindPackageList = new ArrayList<>();
// constructor
public CMakeConfig(String compName) {
cMakeListsViewModel.setCompName(compName);
......@@ -69,7 +67,6 @@ public class CMakeConfig {
cMakeListsViewModel.setCmakeLibraryLinkageList(cmakeLibraryLinkageList);
cMakeListsViewModel.setCmakeCommandList(cmakeCommandList);
cMakeListsViewModel.setCmakeCommandListEnd(cmakeCommandListEnd);
cMakeListsViewModel.setCmakeFindPackageList(cmakeFindPackageList);
}
public List<FileContent> generateCMakeFiles() {
......@@ -159,10 +156,5 @@ public class CMakeConfig {
this.cmakeLibraryLinkageList.add(cmakeLibraryLinkage);
}
public void addFindPackage(String packageName) {
if (!cmakeFindPackageList.contains(packageName))
cmakeFindPackageList.add(packageName);
}
}
......@@ -23,6 +23,7 @@ public class CMakeFindModule extends ViewModelBase {
private Boolean findPath;
private Boolean findLibrary;
private Boolean fortranQuadMath = false;
private Boolean findAsPackage = false;
private boolean required;
......@@ -51,6 +52,15 @@ public class CMakeFindModule extends ViewModelBase {
// methods
public CMakeFindModule asFindAsPackage() {
this.findLibrary = false;
this.findPath = false;
this.findAsPackage = true;
return this;
}
// getters and setters
public String getPackageName() {
return packageName;
}
......@@ -127,6 +137,16 @@ public class CMakeFindModule extends ViewModelBase {
this.fortranQuadMath = fortranQuadMath;
}
public Boolean getFindAsPackage() {
return findAsPackage;
}
public void setFindAsPackage(Boolean findAsPackage) {
this.findAsPackage = findAsPackage;
}
// equals and hashcode
@Override
public boolean equals(Object o) {
if (this == o) return true;
......@@ -140,11 +160,12 @@ public class CMakeFindModule extends ViewModelBase {
Objects.equals(getLibPaths(), that.getLibPaths()) &&
Objects.equals(getFindPath(), that.getFindPath()) &&
Objects.equals(getFindLibrary(), that.getFindLibrary()) &&
Objects.equals(getFortranQuadMath(), that.getFortranQuadMath());
Objects.equals(getFortranQuadMath(), that.getFortranQuadMath()) &&
Objects.equals(getFindAsPackage(), that.getFindAsPackage());
}
@Override
public int hashCode() {
return Objects.hash(getPackageName(), getIncludeName(), getLibName(), getIncludePaths(), getLibPaths(), getFindPath(), getFindLibrary(), getFortranQuadMath(), isRequired());
return Objects.hash(getPackageName(), getIncludeName(), getLibName(), getIncludePaths(), getLibPaths(), getFindPath(), getFindLibrary(), getFortranQuadMath(), getFindAsPackage(), isRequired());
}
}
......@@ -27,8 +27,6 @@ public class CMakeListsCPPViewModel extends ViewModelBase {
private List<String> cmakeLibraryLinkageList = new ArrayList<>();
private List<String> cmakeFindPackageList = new ArrayList<>();
// methods
public String getCompName() {
......@@ -70,12 +68,4 @@ public class CMakeListsCPPViewModel extends ViewModelBase {
public void setCmakeLibraryLinkageList(List<String> cmakeLibraryLinkageList) {
this.cmakeLibraryLinkageList = cmakeLibraryLinkageList;
}
public List<String> getCmakeFindPackageList() {
return cmakeFindPackageList;
}
public void setCmakeFindPackageList(List<String> cmakeFindPackageList) {
this.cmakeFindPackageList = cmakeFindPackageList;
}
}
......@@ -65,9 +65,8 @@ public class BoundingRectCommand extends MathCommand{
mathMatrixNameExpressionSymbol.getMathMatrixAccessOperatorSymbol().setMathMatrixAccessSymbols(newMatrixAccessSymbols);
bluePrintCPP.addCVIncludeString("opencv2/imgproc/imgproc");
bluePrintCPP.getGenerator().getCmakeConfig()
.addFindPackage("OpenCV");
.addModuleDependency(new CMakeFindModule("OpenCV", true).asFindAsPackage());
}
}
......@@ -67,9 +67,8 @@ public class CvtColorCommand extends ArgumentNoReturnMathCommand{
bluePrint.addMethod(cvtColorHelperMethod);
redefineArmaMat(bluePrintCPP);
redefineInit(bluePrintCPP);
bluePrintCPP.getGenerator().getCmakeConfig()
.addFindPackage("OpenCV");
.addModuleDependency(new CMakeFindModule("OpenCV", true).asFindAsPackage());
}
......
......@@ -67,9 +67,8 @@ public class DilateCommand extends ArgumentNoReturnMathCommand{
bluePrint.addMethod(dilateHelperMethod);
redefineArmaMat(bluePrintCPP);
redefineInit(bluePrintCPP);
bluePrintCPP.getGenerator().getCmakeConfig()
.addFindPackage("OpenCV");
.addModuleDependency(new CMakeFindModule("OpenCV", true).asFindAsPackage());
}
private Method getDilateHelperMethod(MathMatrixNameExpressionSymbol mathMatrixNameExpressionSymbol, EMAMBluePrintCPP bluePrintCPP, MathExpressionProperties properties){
......
......@@ -69,9 +69,8 @@ public class ErodeCommand extends ArgumentNoReturnMathCommand{
bluePrint.addMethod(erodeHelperMethod);
redefineArmaMat(bluePrintCPP);
redefineInit(bluePrintCPP);
bluePrintCPP.getGenerator().getCmakeConfig()
.addFindPackage("OpenCV");
.addModuleDependency(new CMakeFindModule("OpenCV", true).asFindAsPackage());
}
......
......@@ -68,9 +68,8 @@ public class FindContoursCommand extends ArgumentNoReturnMathCommand{
bluePrint.addMethod(findContoursHelperMethod);
redefineArmaMat(bluePrintCPP);
redefineInit(bluePrintCPP);
bluePrintCPP.getGenerator().getCmakeConfig()
.addFindPackage("OpenCV");
.addModuleDependency(new CMakeFindModule("OpenCV", true).asFindAsPackage());
}
......
......@@ -67,9 +67,8 @@ public class GaussianBlurCommand extends ArgumentNoReturnMathCommand{
bluePrint.addMethod(gaussianBlurHelperMethod);
redefineArmaMat(bluePrintCPP);
redefineInit(bluePrintCPP);
bluePrintCPP.getGenerator().getCmakeConfig()
.addFindPackage("OpenCV");
.addModuleDependency(new CMakeFindModule("OpenCV", true).asFindAsPackage());
}
private Method getGaussianBlurHelperMethod(MathMatrixNameExpressionSymbol mathMatrixNameExpressionSymbol, EMAMBluePrintCPP bluePrintCPP, MathExpressionProperties properties){
......
......@@ -67,9 +67,8 @@ public class InRangeCommand extends ArgumentNoReturnMathCommand{
bluePrint.addMethod(inRangeHelperMethod);
redefineArmaMat(bluePrintCPP);
redefineInit(bluePrintCPP);
bluePrintCPP.getGenerator().getCmakeConfig()
.addFindPackage("OpenCV");
.addModuleDependency(new CMakeFindModule("OpenCV", true).asFindAsPackage());
}
......
......@@ -66,9 +66,8 @@ public class LargestContourCommand extends MathCommand {
bluePrint.addMethod(largestContourMethod);
redefineArmaMat(bluePrintCPP);
redefineInit(bluePrintCPP);
bluePrintCPP.getGenerator().getCmakeConfig()
.addFindPackage("OpenCV");
.addModuleDependency(new CMakeFindModule("OpenCV", true).asFindAsPackage());
}
......
......@@ -71,9 +71,8 @@ public class RectangleCommand extends MathCommand{
bluePrint.addMethod(rectangleHelperMethod);
redefineArmaMat(bluePrintCPP);
redefineInit(bluePrintCPP);
bluePrintCPP.getGenerator().getCmakeConfig()
.addFindPackage("OpenCV");
.addModuleDependency(new CMakeFindModule("OpenCV", true).asFindAsPackage());
}
......
......@@ -22,7 +22,7 @@ find_path(${viewModel.packageName}_INCLUDE_DIR
<#if viewModel.findLibrary>
find_library(${viewModel.packageName}_LIBRARY
NAMES ${viewModel.libName}
PATH_SUFFIXES "lib" "lib64" "lib/x86_64-linux-gnu" "examples/lib_win64" "build" "Release"
PATH_SUFFIXES "lib" "lib64" "lib/x86_64-linux-gnu" "examples/lib_win64" "build" "Release" "x64" "x86"
PATHS
<#list viewModel.libPaths as var>
"${var}"
......@@ -33,17 +33,33 @@ find_library(${viewModel.packageName}_LIBRARY
include(FindPackageHandleStandardArgs)
# if all listed variables are TRUE
<#if viewModel.findAsPackage>
find_package(${viewModel.packageName}
PATH_SUFFIXES "lib" "lib64" "lib/x86_64-linux-gnu" "examples/lib_win64" "build" "Release" "x64" "x86"
HINTS $ENV{${viewModel.packageName}_HOME}
REQUIRED
)
<#else>
find_package_handle_standard_args(
${viewModel.packageName}
DEFAULT_MSG
<#if viewModel.findPath>${viewModel.packageName}_INCLUDE_DIR</#if>
<#if viewModel.findLibrary>${viewModel.packageName}_LIBRARY</#if>
)
</#if>
mark_as_advanced(
<#if viewModel.findPath>${viewModel.packageName}_INCLUDE_DIR</#if>
<#if viewModel.findLibrary>${viewModel.packageName}_LIBRARY</#if>
<#if viewModel.findPath || viewModel.findAsPackage>${viewModel.packageName}_INCLUDE_DIR</#if>
<#if viewModel.findLibrary>
${viewModel.packageName}_LIBRARY
<#elseif viewModel.findAsPackage>
${viewModel.packageName}_LIBS
</#if>
)
<#if viewModel.findPath>set(${viewModel.packageName}_INCLUDE_DIRS ${r"${"}${viewModel.packageName}${r"_INCLUDE_DIR}"})</#if>
<#if viewModel.findLibrary>set(${viewModel.packageName}_LIBRARIES ${r"${"}${viewModel.packageName}${r"_LIBRARY}"})</#if>
<#if viewModel.findPath || viewModel.findAsPackage>set(${viewModel.packageName}_INCLUDE_DIRS ${r"${"}${viewModel.packageName}${r"_INCLUDE_DIR}"})</#if>
<#if viewModel.findLibrary>
set(${viewModel.packageName}_LIBRARIES ${r"${"}${viewModel.packageName}${r"_LIBRARY}"})
<#elseif viewModel.findAsPackage>
set(${viewModel.packageName}_LIBRARIES ${r"${"}${viewModel.packageName}${r"_LIBS}"})
</#if>
......@@ -10,19 +10,14 @@ set(CMAKE_MODULE_PATH ${r"${CMAKE_MODULE_PATH}"} ${r"${CMAKE_CURRENT_SOURCE_DIR}
# add dependencies
<#list viewModel.moduleDependencies as var>
find_package(${var.packageName} <#if var.required>REQUIRED<#else></#if>)
<#if var.findPath>set(INCLUDE_DIRS ${r"${INCLUDE_DIRS}"} ${r"${"}${var.packageName}${r"_INCLUDE_DIRS}"})</#if>
<#if var.findLibrary>set(LIBS ${r"${LIBS}"} ${r"${"}${var.packageName}${r"_LIBRARIES}"})</#if>
<#if var.findPath || var.findAsPackage>set(INCLUDE_DIRS ${r"${INCLUDE_DIRS}"} ${r"${"}${var.packageName}${r"_INCLUDE_DIRS}"})</#if>
<#if var.findLibrary || var.findAsPackage>set(LIBS ${r"${LIBS}"} ${r"${"}${var.packageName}${r"_LIBRARIES}"})</#if>
<#if var.fortranQuadMath>set(LIBS ${r"${LIBS}"} "quadmath")</#if>
</#list>
<#list viewModel.cmakeFindPackageList as cmd>
find_package(${cmd} REQUIRED)
set(INCLUDE_DIRS ${r"${INCLUDE_DIRS}"} ${r"${"}${cmd}${r"_INCLUDE_DIRSr}"})
set(LIBS ${r"${LIBS}"} ${r"${"}${cmd}${r"_LIBS}"})
</#list>
# additional library linkage
<#list viewModel.cmakeLibraryLinkageList as cmd>
set(LIBS ${r"${LIBS}"} ${cmd})
<#list viewModel.cmakeLibraryLinkageList as lib>
set(LIBS ${r"${LIBS}"} ${lib})
</#list>
# additional commands
......
......@@ -16,7 +16,7 @@ find_path(Armadillo_INCLUDE_DIR
)
find_library(Armadillo_LIBRARY
NAMES armadillo
PATH_SUFFIXES "lib" "lib64" "lib/x86_64-linux-gnu" "examples/lib_win64" "build" "Release"
PATH_SUFFIXES "lib" "lib64" "lib/x86_64-linux-gnu" "examples/lib_win64" "build" "Release" "x64" "x86"
PATHS
HINTS $ENV{Armadillo_HOME}
)
......
......@@ -16,7 +16,7 @@ find_path(Armadillo_INCLUDE_DIR
)
find_library(Armadillo_LIBRARY
NAMES armadillo
PATH_SUFFIXES "lib" "lib64" "lib/x86_64-linux-gnu" "examples/lib_win64" "build" "Release"
PATH_SUFFIXES "lib" "lib64" "lib/x86_64-linux-gnu" "examples/lib_win64" "build" "Release" "x64" "x86"
PATHS
HINTS $ENV{Armadillo_HOME}
)
......
......@@ -16,7 +16,7 @@ find_path(Armadillo_INCLUDE_DIR
)
find_library(Armadillo_LIBRARY
NAMES armadillo
PATH_SUFFIXES "lib" "lib64" "lib/x86_64-linux-gnu" "examples/lib_win64" "build" "Release"
PATH_SUFFIXES "lib" "lib64" "lib/x86_64-linux-gnu" "examples/lib_win64" "build" "Release" "x64" "x86"
PATHS
HINTS $ENV{Armadillo_HOME}
)
......
......@@ -16,7 +16,7 @@ find_path(Armadillo_INCLUDE_DIR
)
find_library(Armadillo_LIBRARY
NAMES armadillo
PATH_SUFFIXES "lib" "lib64" "lib/x86_64-linux-gnu" "examples/lib_win64" "build" "Release"
PATH_SUFFIXES "lib" "lib64" "lib/x86_64-linux-gnu" "examples/lib_win64" "build" "Release" "x64" "x86"
PATHS
HINTS $ENV{Armadillo_HOME}
)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment