Simple C/C++ project archetype for CLion IDE and Maven NAR plugin.
This archetype will generate a simple and ready to be used project for the outstanding CLion IDE.
It uses the Maven NAR plugin to take advantage of repositories of dependencies/libraries and a standard lifecycle model for projects (it is used as a de facto standar in Java).
Now you could code in your favorite IDE (CLion obviously) and compile, test and install/deploy your C/C++ projects/libraries in a local or external repository. For now, CLion doesn't support the Maven NAR plugin, you will need to use the Terminal (ALT+F12) to send simple commands like "mvn compile".
Then, if you want to use your library in another project you only need to add the dependency in your pom.xml
like this:
<dependency>
<groupId>org.opencv</groupId>
<artifactId>opencv-core</artifactId>
<version>2.4.10</version>
<type>nar</type>
</dependency>
For starters you need to:
- have Maven installed (and know the basics of it)
- install the archetype (clion-executable-install.bat)
- create a project using the archetype (clion-executable-new-project.bat)
- use a command line and execute
mvn test
(your compiler must be in your PATH or you could configure it inpom.xml
)
- add your required
<dependencies/>
inpom.xml
- execute
mvn compile
in the Terminal (Maven will bring your dependencies headers and libraries) - add the
include_directories
andtarget_link_libraries
inCMakeLists.txt
and reload the project. - enjoy CLion! You could find some library dependencies in https://github.com/lmiguelmh/ and https://github.com/maven-nar/nar-maven-plugin/wiki/Working-examples
If you want to build your own dependencies from compiled libraries follow this SO answer (don't forget to give +1): http://stackoverflow.com/questions/34076669/add-a-static-library-for-the-link-phase-of-a-maven-nar-project
For system libraries you can add them in your source or use <linker/>
in the pom.xml
file:
#pragma comment(lib, "user32.lib")
#pragma comment(lib, "gdi32.lib")
#pragma comment(lib, "advapi32.lib")
...
Every dependency marked as a static or shared library could be used in other projects.
-
modify the
<configuration/>
on yourpom.xml
<!-- shared library <library> <type>shared</type> </library> --> </libraries>
-
open the terminal and compile (
mvn compile
) and install your library on the repository (mvn install
) -
open your project and add the dependency in your
pom.xml
, for example:<dependency> <groupId>lmiguelmh.commons</groupId> <artifactId>commons</artifactId> <version>1.0</version> <type>nar</type> </dependency>
For setting which toolset and sdk to use, you could override automatic detection with the next configuration in your pom.xml
. In older versions this will fix some issues too http://stackoverflow.com/q/35903652/2692914 http://stackoverflow.com/q/35898892/2692914
<msvc>
<version>11.0</version>
<windowsSdkVersion>8.0</windowsSdkVersion>
</msvc>
Finally, you should visit:
- the official Maven page: http://maven.apache.org
- the official Maven NAR plugin page: https://github.com/maven-nar/nar-maven-plugin/wiki