I am trying to Mavenize a C++ project with nar-maven, on Windows with MSVC. It is a shared library.
I already tested successfully nar-maven on sample projects with this archetype .
So now, I need to use the nar-maven-plugin for a bigger project. In order to compile successfully, I need to add some arguments (includes, libs, preprocessor definitions...). And this is where I am stuck. Here is a sample of my current pom file :
<project>
...
<properties>
<skipTests>true</skipTests>
</properties>
<build>
<defaultGoal>integration-test</defaultGoal>
<plugins>
<plugin>
<groupId>com.github.maven-nar</groupId>
<artifactId>nar-maven-plugin</artifactId>
<version>3.5.0</version>
<extensions>true</extensions>
<configuration>
<options>
<option>/D_WINDOWS</option>
<option>/D_WINDLL</option>
<option>...</option>
</options>
<libraries>
<library>
<type>shared</type>
</library>
</libraries>
<tests>
<test>
<name>libblawin</name>
<link>shared</link>
</test>
</tests>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
...
</dependencies>
</project>
Whatever parameter I add (options tag, includes tag...) within the configuration tag, it is not taken in account by maven. Indeed, when I look for the command line used to compile a source file (using the -X option with mvn) the options added in the pom.xml are not included.
The command line used by maven :
Executing 'C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\amd64\cl' with arguments:
''
'/c'
'/nologo'
'/EHsc'
'/DNDEBUG'
'/MD'
'/GR'
'/FdD:\NAR-projects\srt\target\nar\obj\amd64-Windows-msvc\'
'/DWIN32'
'/ID:\NAR-projects\srt\target\nar\obj\amd64-Windows-msvc'
'/ID:\NAR-projects\srt\target\nar\obj\amd64-Windows-msvc'
'/ID:\NAR-projects\srt\src\main\include'
'/IC:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include'
'/IC:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\atlmfc\include'
'/IC:\Program Files (x86)\Windows Kits\8.1\Include\shared'
'/IC:\Program Files (x86)\Windows Kits\8.1\Include\um'
'/IC:\Program Files (x86)\Windows Kits\8.1\Include\winrt'
'/FoD:\NAR-projects\srt\target\nar\obj\amd64-Windows-msvc\libraryExtern.1d1757c3.obj'
'include/interapp/libraryExtern.cpp'
Anyway, I think that I am doing something wrong, and I hope you can help. I need to find a way to configure my project as I want.
I figured.
I browsed the working examples in order to see where my mistake was, and on this particular example, imagej-launcher , we can see that it adds all the compiler configuration inside a c tag :
<configuration>
<c>
<name>gcc</name>
<includes>
<include>**/*.c</include>
</includes>
<options>
<option>-DLAUNCHER_VERSION="${project.version}"</option>
<option>-DBUILD_NUMBER="${buildNumber}"</option>
<option>-I${JAVA_HOME}/include</option>
<option>${java.os.include}</option>
<option>${stack.protector.option}</option>
<option>${architecture.option}</option>
<option>${subsystem.option}</option>
<option>${debug.option}</option>
</options>
</c>
...
So I just added a cpp tag and put my options in it, and now it works fine :
<configuration>
<cpp>
<options>
<option>/D_WINDOWS</option>
<option>/D_WINDLL</option>
<option>...</option>
</options>
</cpp>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.