From c79758f44a19ee0759a7615d4286dcaa670fbb05 Mon Sep 17 00:00:00 2001 From: Powsybl Date: Wed, 4 Sep 2019 16:45:20 +0200 Subject: [PATCH] Add support for MacOSX Signed-off-by: Mathieu BAGUE --- CMakeLists.txt | 30 ++++++++++++++++------- README.md | 64 +++++++++++++++++++++++++------------------------- pom.xml | 2 +- 3 files changed, 55 insertions(+), 41 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index fe7a7c9..9ad7d1e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -32,10 +32,16 @@ if(WIN32) set(SUITE_SPARSE_LIB_DIR ${THIRD_PARTY_DIR}/suitesparse/lib) set(SUITE_SPARSE_LIB_SUFFIX d.lib) set(SUITE_SPARSE_CONFIG_LIB ${SUITE_SPARSE_LIB_DIR}/suitesparseconfig${SUITE_SPARSE_LIB_SUFFIX}) -else() - set(SUITE_SPARSE_LIB_DIR ${THIRD_PARTY_DIR}/suitesparse/lib64) +elseif(UNIX) + if (${CMAKE_SYSTEM_NAME} STREQUAL "Darwin") + set(SUITE_SPARSE_LIB_DIR ${THIRD_PARTY_DIR}/suitesparse/lib) + else() + set(SUITE_SPARSE_LIB_DIR ${THIRD_PARTY_DIR}/suitesparse/lib64) + endif() set(SUITE_SPARSE_LIB_SUFFIX ${CMAKE_STATIC_LIBRARY_SUFFIX}) set(SUITE_SPARSE_CONFIG_LIB ${SUITE_SPARSE_LIB_DIR}/${SUITE_SPARSE_LIB_PREFIX}suitesparseconfig${SUITE_SPARSE_LIB_SUFFIX}) +else() + message(FATAL_ERROR "System not supported: ${CMAKE_SYSTEM_NAME}") endif() set(SUITE_SPARSE_AMD_LIB ${SUITE_SPARSE_LIB_DIR}/${SUITE_SPARSE_LIB_PREFIX}amd${SUITE_SPARSE_LIB_SUFFIX}) @@ -61,12 +67,20 @@ target_include_directories(math ${SUITE_SPARSE_INCLUDE} ) -if(${CMAKE_SYSTEM_NAME} MATCHES "Linux" AND ${CMAKE_SYSTEM_PROCESSOR} MATCHES "x86_64") - set(ARCHITECTURE linux_64) -elseif(${CMAKE_SYSTEM_NAME} MATCHES "Windows" AND ${CMAKE_SYSTEM_PROCESSOR} MATCHES "AMD64") - set(ARCHITECTURE windows_64) +if (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "x86_64" OR ${CMAKE_SYSTEM_PROCESSOR} STREQUAL "AMD64") + set(OS_BITS 64) +else() + set(OS_BITS 32) +endif() + +if(${CMAKE_SYSTEM_NAME} STREQUAL "Windows") + set(ARCHITECTURE windows_${OS_BITS}) +elseif(${CMAKE_SYSTEM_NAME} STREQUAL "Linux") + set(ARCHITECTURE linux_${OS_BITS}) +elseif(${CMAKE_SYSTEM_NAME} STREQUAL "Darwin") + set(ARCHITECTURE osx_${OS_BITS}) else() - message(FATAL_ERROR "System not supported: ${CMAKE_SYSTEM_NAME} ${CMAKE_SYSTEM_PROCESSOR}") + message(FATAL_ERROR "System not supported: ${CMAKE_SYSTEM_NAME}") endif() if(WIN32) @@ -74,7 +88,7 @@ if(WIN32) PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/target/classes/natives/${ARCHITECTURE}" ) -else() +elseif(UNIX) set_target_properties(math PROPERTIES LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/target/classes/natives/${ARCHITECTURE}" diff --git a/README.md b/README.md index b516bd0..7ce660a 100644 --- a/README.md +++ b/README.md @@ -1,37 +1,37 @@ -# Linux build +# powsybl-math-native +This project is the C++ implementation of [powsybl-math](https://github.com/powsybl/powsybl-core) `SparseMatrix` class, relying on SuiteSparse project. -Everything is automated on Linux using a Dockerfile. To build Docker image, run the following command (proxy related arguments are optionals). +## Requirements +To build `powsybl-math-native`, you need the followind dependencies: +- [CMake](https://cmake.org/download) +- C++ compiler (gcc, clang or [Visual Studio](https://visualstudio.microsoft.com/fr/vs/features/cplusplus/)) +- Java (8 or later) +- [Python](https://www.python.org/downloads) (2.7 or later), with [Six](https://pypi.org/project/six/) module -```bash -docker build -t powsybl-math-native --build-arg proxy_host= --build-arg proxy_port= --build-arg proxy_username= --build-arg proxy_password= . -``` - -Once docker image has been built, we can retrieved native jar: +## Compilation -```bash -docker run --name powsybl-math-native-tmp powsybl-math-native /bin/true -docker cp powsybl-math-native-tmp:/powsybl-math-native/build/powsybl-math-linux_64-1.0.0.jar /tmp -docker rm powsybl-math-native-tmp +### Linux or MacOS +To build `powsybl-math-native`, run the following commands: ``` - -# Windows build - -Following components have to be installed: - - - Git for Windows: https://gitforwindows.org/ - - CMake >= 3.1: https://cmake.org/download/. It must be added to the path. - - Python 2.7 for Windows: https://www.python.org/downloads/windows/ - - Python27 must be added to the path - - Six module must be installed. In a cmd.exe shell run the following command: -```bash -python -m pip install six -``` - - Visual studio c++ compiler community edition: https://visualstudio.microsoft.com/fr/vs/features/cplusplus/ - -# Jar installation - -To install jars in local repository: - -```bash -mvn install +$> git clone https://github.com/powsybl/powsybl-math-native.git +$> cd powsybl-math-native +$> mkdir build +$> cd build +$> cmake .. +$> make +$> cd .. +$> mvn install +```` + +### Windows +To build `powsybl-math-native`, run the following commands: ``` +$> git clone https://github.com/powsybl/powsybl-math-native.git +$> cd powsybl-math-native +$> mkdir build +$> cd build +$> cmake .. -G "NMake Makefiles" +$> nmake +$> cd .. +$> mvn install +```` diff --git a/pom.xml b/pom.xml index 3db2ce4..acbaeb5 100644 --- a/pom.xml +++ b/pom.xml @@ -12,7 +12,7 @@ com.powsybl powsybl-math-native - 1.0.0 + 1.0.1 jar Math native