Giter Club home page Giter Club logo

cmake-maven-project's Introduction

CMake-Maven-Project Build Status

Introduction

A Maven project for the CMake build system. It can be used by including it as a plugin within your Maven project's pom.xml file.

This repository originally lived on Google Code and was migrated to GitHub (and Git) after Google Code shut down.

Sample Usage

Generate Goal

<plugin>
  <groupId>com.googlecode.cmake-maven-project</groupId>
  <artifactId>cmake-maven-plugin</artifactId>
  <version>3.7.2-b1</version>
  <executions>
    <execution>
      <id>cmake-generate</id>
      <goals>
        <goal>generate</goal>
      </goals>
      <configuration>
        <sourcePath>
          <!-- The directory containing CMakeLists -->
        </sourcePath>
        <targetPath>
          <!-- The directory write the project files to -->
        </targetPath>
        <generator>
          <!-- One of the generators defined at https://cmake.org/cmake/help/v3.7/manual/cmake-generators.7.html -->
        </generator>
        <classifier>
          <!-- The classifier of the current platform. One of [windows-x86_32, windows-x86_64, linux-x86_32, linux-x86_64, linux-arm_32, mac-x86_64]. -->
        </classifier>
        <environmentVariables>
          <key>value</key>
        </environmentVariables>
        <options>
          <!--
            Optional: One or more options found at https://cmake.org/cmake/help/v3.7/manual/cmake.1.html
            For example:
          -->
          <option>-DBUILD_THIRDPARTY:bool=on</option>
        </options>
      </configuration>
    </execution>
  </executions>
</plugin>

Compile Goal

<plugin>
  <groupId>com.googlecode.cmake-maven-project</groupId>
  <artifactId>cmake-maven-plugin</artifactId>
  <version>3.7.2-b1</version>
  <executions>
    <execution>
      <id>cmake-compile</id>
      <goals>
        <goal>compile</goal>
      </goals>
      <configuration>
        <config>
          <!-- Optional: the build configuration (e.g. "Release|x64") -->
        </config>
        <target>
          <!-- Optional: the build "target" -->
        </target>
        <projectDirectory>
          <!-- "targetPath" from the "generate" goal -->
        </projectDirectory>
        <classifier>
          <!-- The classifier of the current platform. One of [windows-x86_32, windows-x86_64, linux-x86_32, linux-x86_64, linux-arm_32, mac-x86_64]. -->
        </classifier>
        <environmentVariables>
          <key>value</key>
        </environmentVariables>
      </configuration>
    </execution>
  </executions>
</plugin>

Test Goal

<plugin>
  <groupId>com.googlecode.cmake-maven-project</groupId>
  <artifactId>cmake-maven-plugin</artifactId>
  <version>3.7.2-b1</version>
  <executions>
    <execution>
      <id>cmake-test</id>
      <goals>
        <goal>test</goal>
      </goals>
      <configuration>
        <!-- "buildDirectory" is "targetPath" from the "generate" goal -->
        <buildDirectory>${project.build.directory}</buildDirectory>
        <!-- Optional way to not fail the build on test failures -->
        <!-- <testFailureIgnore>true</testFailureIgnore> -->
        <!-- Optional way to skip just the ctest tests -->
        <!-- <ctest.skip.tests>true</ctest.skip.tests> -->
        <!-- Optional/standard way to skip all Maven tests -->
        <!-- <maven.test.skip>true</maven.test.skip> -->
        <!-- Optional way to configure number of threads tests should use -->
        <!-- <threadCount>2</threadCount> -->
        <!-- Optional dashboard configuration; used with CTestConfig.cmake -->
        <!-- <dashboard>Experimental</dashboard> -->
      </configuration>
    </execution>
  </executions>
</plugin>

Examples

The following projects contain examples of how to use this plugin:

Requirements API

Building instructions

To build the plugin, run:

mvn install

To clean an old build, run:

mvn clean

By default, Maven will activate the right profile based on your JVM:

  • windows-x86_32
  • windows-x86_64
  • linux-x86_32
  • linux-x86_64
  • linux-arm_32
  • mac-x86_64

If detection does not work, or you wish to override it (e.g. you're running linux-x86_64 but want to cross-compile for linux-x86_32) then set -DosDetection=false -P<profile>.

For instance, when building for 32-bit Linux machines, use:

mvn -DosDetection=false -Plinux-x86_32 install

Using a local CMake installation

cmake.org doesn't provide binaries for some platforms, such as 32-bit Linux and Raspberry Pi. In such cases, users can install the binaries themselves (typically using package managers like apt-get) and point the plugin at them.

The following Maven profiles use local CMake installations:

  • linux-x86_32 corresponds to the 32-bit Linux platform.
  • linux-arm_32 corresponds to the Rasbian (Raspberry Pi) platform.

but you can configure this behavior for any platform by setting ${download.cmake} to false. The plugin looks for cmake under ${cmake.root.dir}/${cmake.child.dir} and ctest under ${cmake.root.dir}/${cmake.ctest.dir}. By default, ${cmake.root.dir} resolves to /usr, ${cmake.child.dir} to /bin/cmake and ${cmake.test.dir} to /.

That's it! To learn more about CMake itself, consult the CMake.org website.

License

CMake-Maven-Project is released under an Apache License 2.0

cmake-maven-project's People

Contributors

ksclarke avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.