Skip to content

Commit a008cbe

Browse files
authored
Simplify Travis-CI logic, add macOS builds (#11)
1 parent 0dda439 commit a008cbe

File tree

3 files changed

+43
-34
lines changed

3 files changed

+43
-34
lines changed

.travis.yml

+15-12
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,21 @@ cache:
55
- '$HOME/.m2'
66
- '$HOME/.jabba/jdk'
77

8-
9-
addons:
10-
apt:
11-
packages:
12-
- cmake
13-
- make
14-
- gcc
15-
- g++
16-
- libc6-dev
17-
18-
19-
script: mvn --fail-never --batch-mode test
8+
matrix:
9+
include:
10+
- os: linux
11+
addons:
12+
apt:
13+
packages:
14+
- cmake3
15+
- g++
16+
- os: osx
17+
addons:
18+
homebrew:
19+
packages:
20+
- cmake
21+
22+
script: mvn --batch-mode test
2023

2124
after_success:
2225
- bash <(curl -s https://codecov.io/bash)

CMakeLists.txt

+22-14
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,7 @@
1-
cmake_minimum_required(VERSION 2.7)
2-
project(jssc
3-
# FIXME: add back if we can get the cmake min version > 3.
4-
# VERSION 2.7.1
5-
# FIXME: Dropped Languages for cmake <3.0 for now.
6-
#LANGUAGES CXX
7-
)
8-
9-
# not supported in early cmake versions.
10-
# DESCRIPTION "Java Simple Serial Connector"
1+
cmake_minimum_required(VERSION 3.0)
2+
cmake_policy(SET CMP0048 NEW)
3+
cmake_policy(SET CMP0042 NEW)
4+
project(jssc VERSION 2.7.1 LANGUAGES CXX)
115

126
find_package(Java)
137
find_package(JNI)
@@ -70,17 +64,31 @@ list(APPEND JSSC_ADDITIONAL_INCLUDES target/nar/javah-include/)
7064

7165
# output to maven conventions to target/generated-sources/<generator>
7266
# The other part will be in conventions to native-lib-loader.
73-
# FIXME: get platorm name from maven(?) or by using if/else/endif
74-
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ../classes/META-INF/lib/linux_64)
67+
68+
# linux, macos, etc
69+
string(TOLOWER "${CMAKE_SYSTEM_NAME}" OS_NAME)
70+
if(APPLE)
71+
# scijava expects "osx", not "darwin"
72+
set(OS_NAME "osx")
73+
endif()
74+
75+
# 32-bit or 64-bit
76+
if("${CMAKE_SIZEOF_VOID_P}" EQUAL "8")
77+
set(OS_BITS 64)
78+
else()
79+
set(OS_BITS 32)
80+
endif()
81+
82+
# library (e.g. linux_64.so) TODO: Handle arm, hardfloat, etc
83+
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ../classes/META-INF/lib/${OS_NAME}_${OS_BITS})
7584

7685
add_library(jssc SHARED
7786
src/cpp/${JSSC_PLATFORM}/jssc.cpp
7887
)
7988

8089
target_include_directories(jssc PRIVATE ${JNI_INCLUDE_DIRS} ${JSSC_ADDITIONAL_INCLUDES})
8190

82-
# FIXME: add back if we can get the cmake min version > 3.
83-
# set_target_properties(jssc PROPERTIES VERSION ${PROJECT_VERSION})
91+
set_target_properties(jssc PROPERTIES VERSION ${PROJECT_VERSION})
8492
set_target_properties(jssc PROPERTIES PUBLIC_HEADER target/nar/javah-include/jssc_SerialNativeInterface.h)
8593
set_target_properties(jssc PROPERTIES POSITION_INDEPENDENT_CODE ON)
8694

pom.xml

+6-8
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
<maven.compiler.release>6</maven.compiler.release>
1515
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
1616

17-
<!-- used to skip javah execution for java9+, see profile below. -->
17+
<!-- skip javah execution for java9+, see profile below. -->
1818
<javah.skip>false</javah.skip>
1919
<cmake.download.binaries>false</cmake.download.binaries>
2020
<!-- cmake maven plugin -->
@@ -87,14 +87,13 @@
8787
<configuration>
8888
<sourcePath>${project.basedir}</sourcePath>
8989
<targetPath>${project.build.directory}/cmake</targetPath>
90+
<!--FIXME "Makefiles" should be optional see cmake-maven-project/cmake-maven-project#7 -->
9091
<generator>Unix Makefiles</generator>
92+
<!--TODO Use -DCMAKE_TOOLCHAIN_FILE file for cross-compile
9193
<options>
92-
<!--
93-
Optional: One or more options found at https://cmake.org/cmake/help/v3.7/manual/cmake.1.html
94-
For example:
95-
-->
96-
<option>-DBUILD_THIRDPARTY:bool=on</option>
94+
<option>-DCMAKE_TOOLCHAIN_FILE=toolchain/Mingw64.cmake</option>
9795
</options>
96+
-->
9897
</configuration>
9998
</execution>
10099

@@ -169,13 +168,12 @@
169168
</properties>
170169
</profile>
171170

172-
<!-- cmake mac (any arch) profile -->
171+
<!-- cmake mac profile -->
173172
<profile>
174173
<id>cmake-macos</id>
175174
<activation>
176175
<os>
177176
<family>mac</family>
178-
<!-- any arch -->
179177
</os>
180178
</activation>
181179
<properties>

0 commit comments

Comments
 (0)