Skip to content

Commit

Permalink
Merge pull request #3 from powsybl/macos
Browse files Browse the repository at this point in the history
Add support for MacOSX
  • Loading branch information
geofjamg authored Sep 5, 2019
2 parents c2cfa63 + c79758f commit 4d57ac2
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 41 deletions.
30 changes: 22 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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})
Expand All @@ -61,20 +67,28 @@ 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)
set_target_properties(math
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}"
Expand Down
64 changes: 32 additions & 32 deletions README.md
Original file line number Diff line number Diff line change
@@ -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=<HOST> --build-arg proxy_port=<PORT> --build-arg proxy_username=<USER> --build-arg proxy_password=<PWD> .
```

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
````
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

<groupId>com.powsybl</groupId>
<artifactId>powsybl-math-native</artifactId>
<version>1.0.0</version>
<version>1.0.1</version>
<packaging>jar</packaging>

<name>Math native</name>
Expand Down

0 comments on commit 4d57ac2

Please sign in to comment.