Skip to content

Commit

Permalink
Merge pull request #10 from fredboudon/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
fredboudon authored Jan 29, 2020
2 parents 982c242 + 17bbd5c commit da1d4f4
Show file tree
Hide file tree
Showing 165 changed files with 1,981 additions and 1,108 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ build-scons_qt5
*.so
*.dll
*.dblite
*.lib

# Distribution / packaging
.Python
Expand Down
83 changes: 83 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
# --- CMake Modules

cmake_minimum_required(VERSION 3.12)
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
include("Anaconda")
include("pywrapper")

# --- L-Py Project

project(lpy_project CXX)

# --- Build setup

set(CMAKE_SKIP_BUILD_RPATH FALSE)
set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)

list(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${CMAKE_INSTALL_PREFIX}/lib" isSystemDir)

if("${isSystemDir}" STREQUAL "-1")
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
endif("${isSystemDir}" STREQUAL "-1")



# --- CXX11 Compilation

set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_CXX_FLAGS_RELEASE "-O2 -DNDEBUG")

# --- (Win32) Multithreaded Compilation

if (MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP")
endif()


## ###################################################################
## Dependencies
## ###################################################################

# --- Python

find_package (Python3 COMPONENTS Interpreter Development)
include_directories(${Python3_INCLUDE_DIRS})

# --- Libraries

find_package(Threads REQUIRED)
find_package(Qt5Core CONFIG REQUIRED)
find_package(Qt5Concurrent CONFIG REQUIRED)
find_package(PlantGL REQUIRED)

if (USE_CONDA)
set(BOOST_ROOT ${CONDA_ENV})
endif()

set(Boost_NO_SYSTEM_PATHS ON)
set(Boost_USE_MULTITHREAD ON)
set(Boost_USE_STATIC_LIBS OFF)
set(BUILD_SHARED_LIBS ON)

find_package(Boost COMPONENTS system python REQUIRED)

# --- Include Directories

include_directories("src/cpp")

include_directories(${Boost_INCLUDE_DIR})

# --- Library Directory

if (DEFINED CONDA_ENV)
link_directories("${CONDA_ENV}/lib")
endif()

# --- Source Directories

add_subdirectory("src/cpp")
add_subdirectory("src/wrapper")
51 changes: 0 additions & 51 deletions SConstruct

This file was deleted.

2 changes: 2 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ install:
- git clone https://github.com/OpenAlea/appveyor-ci.git appveyor-ci
- cd appveyor-ci
- call install.bat
- conda config --prepend channels conda-forge
- conda config --prepend channels fredboudon

before_build:
- call before_build.bat
Expand Down
1 change: 1 addition & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
conda build . -c conda-forge -c fredboudon -c defaults --python=3.7
68 changes: 68 additions & 0 deletions cmake/Anaconda.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# Anaconda Check
if (DEFINED ENV{CONDA_PREFIX})
# Anaconda Environment
message(STATUS "Anaconda environment detected: " $ENV{CONDA_PREFIX})


if (DEFINED ENV{BUILD_PREFIX})
file(TO_CMAKE_PATH $ENV{BUILD_PREFIX} TMP_CONDA_ENV)
else()
file(TO_CMAKE_PATH $ENV{CONDA_PREFIX} TMP_CONDA_ENV)
endif()

if (WIN32)
set(CONDA_ENV "${TMP_CONDA_ENV}/Library/")
else()
set(CONDA_ENV "${TMP_CONDA_ENV}/")
endif()

set(CONDA_PYTHON_ENV "${TMP_CONDA_ENV}/")

set(USE_CONDA ON)

else()
message(STATUS "Compilation outside an anaconda environment.")
set(USE_CONDA OFF)
endif()


if (DEFINED ENV{CONDA_BUILD})
message(STATUS "Conda build detected. " $ENV{CONDA_BUILD})

# specify the cross compiler
set(CMAKE_C_COMPILER $ENV{CC})
set(CMAKE_LINKER $ENV{LD})
set(CMAKE_AR $ENV{AR})
set(CMAKE_NM $ENV{NM})
set(CMAKE_RANLIB $ENV{RANLIB})
set(CMAKE_STRIP $ENV{STRIP})
set(CMAKE_INSTALL_NAME_TOOL $ENV{INSTALL_NAME_TOOL})
#CMAKE_MAKE_PROGRAM
#CMAKE_OBJCOPY
#CMAKE_OBJDUMP

if (APPLE)
set(CMAKE_OSX_ARCHITECTURES $ENV{OSX_ARCH})
endif()

set(CMAKE_CXX_COMPILER $ENV{CXX})
set(CMAKE_CXX_COMPILER_RANLIB $ENV{RANLIB})
set(CMAKE_CXX_COMPILER_AR $ENV{AR})

# where is the target environment
set(CMAKE_FIND_ROOT_PATH $ENV{PREFIX} $ENV{BUILD_PREFIX} $ENV{BUILD_PREFIX}/$ENV{HOST}/sysroot $ENV{CONDA_BUILD_SYSROOT})

# search for programs in the build host directories
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
# for libraries and headers in the target directories
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)


set(USE_CONDA_BUILD ON)
else()
set(USE_CONDA_BUILD OFF)
endif()



25 changes: 25 additions & 0 deletions cmake/CXX14.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Compiler Check
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
# Clang (Min 3.4)
if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.4)
message(FATAL_ERROR "Clang 3.4 or greater is required.")
endif()
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
# GCC (Min 5.1)
if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.1)
message(FATAL_ERROR "GCC 5.1 or greater is required.")
endif()
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
# Visual C++ (Min 14.0)
if (MSVC_VERSION LESS 1900)
message(FATAL_ERROR "Microsoft Visual C++ 14.0 (Visual Studio 2015) or greater is required.")
endif()
else()
# Other Compilers
message(WARNING "You are using an unknown compiler. It may not be supported.")
endif()

# C++14 Standard
#set(CMAKE_CXX_STANDARD 14)
#set(CMAKE_CXX_STANDARD_REQUIRED ON)
#set(CMAKE_CXX_EXTENSIONS OFF)
136 changes: 136 additions & 0 deletions cmake/FindPlantGL.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
foreach(v PLANTGL_INCLUDEDIR PLANTGL_LIBRARYDIR)
set(_env $ENV{${v}})
endforeach()

#set(PGL_DEBUG ON)

if (PLANTGL_ROOT)
if(PGL_DEBUG)
message(STATUS "PLANTGL_ROOT: " ${PLANTGL_ROOT})
endif()
if (NOT PLANTGL_INCLUDEDIR)
set(PLANTGL_INCLUDEDIR ${PLANTGL_ROOT}/include)
endif()
if (NOT PLANTGL_LIBRARYDIR)
set(PLANTGL_LIBRARYDIR ${PLANTGL_ROOT}/lib)
endif()
endif()

if (PGL_DEBUG AND PLANTGL_INCLUDEDIR)
message(STATUS "PLANTGL_INCLUDEDIR: " ${PLANTGL_INCLUDEDIR})
endif()

if (PGL_DEBUG AND PLANTGL_LIBRARYDIR)
message(STATUS "PLANTGL_LIBRARYDIR: " ${PLANTGL_LIBRARYDIR})
endif()

# Include Directory
find_path(PLANTGL_INCLUDE_DIR
NAMES "plantgl/plantgl.h"
HINTS ${PLANTGL_INCLUDEDIR} $ENV{PATH} $ENV{CONDA_PREFIX}/include)

if (NOT PLANTGL_INCLUDE_DIR)
set(PLANTGL_FOUND OFF)

if (PlantGL_FIND_REQUIRED)
# PlantGL not found
message(SEND_ERROR "Unable to find PlantGL headers.")
endif()
endif()

# Library Directory
find_library(PLANTGL_SG_LIBRARY
NAMES "pglsg" "libpglsg"
PATHS ${PLANTGL_LIBRARYDIR} $ENV{PATH} $ENV{CONDA_PREFIX}/lib $ENV{CONDA_PREFIX}/lib64)

get_filename_component(PLANTGL_LIBRARY_DIR ${PLANTGL_SG_LIBRARY} DIRECTORY)

if (NOT PLANTGL_LIBRARY_DIR)
set(PLANTGL_FOUND OFF)

if (PlantGL_FIND_REQUIRED)
# PlantGL not found
message(SEND_ERROR "Unable to find PlantGL libraries repository.")
endif()
endif()


if (PLANTGL_INCLUDE_DIR AND PLANTGL_LIBRARY_DIR)
set(PLANTGL_FOUND ON)
# PlantGL found
message(STATUS "Found PlantGL: TRUE")

find_library(PLANTGL_MATH_LIBRARY
NAMES "pglmath" "libpglmath"
PATHS ${PLANTGL_LIBRARY_DIR} $ENV{PATH})
if (NOT PLANTGL_MATH_LIBRARY)
message(SEND_ERROR "Unable to find PlantGL math library.")
endif()

find_library(PLANTGL_TOOL_LIBRARY
NAMES "pgltool" "libpgltool"
PATHS ${PLANTGL_LIBRARY_DIR} $ENV{PATH})
if (NOT PLANTGL_TOOL_LIBRARY)
message(SEND_ERROR "Unable to find PlantGL tool library.")
endif()

find_library(PLANTGL_ALGO_LIBRARY
NAMES "pglalgo" "libpglalgo"
PATHS ${PLANTGL_LIBRARY_DIR} $ENV{PATH})
if (NOT PLANTGL_ALGO_LIBRARY)
message(SEND_ERROR "Unable to find PlantGL algo library.")
endif()

find_library(PLANTGL_GUI_LIBRARY
NAMES "pglgui" "libpglgui"
PATHS ${PLANTGL_LIBRARY_DIR} $ENV{PATH})
if (NOT PLANTGL_GUI_LIBRARY)
message(SEND_ERROR "Unable to find PlantGL gui library.")
endif()

set(PLANTGL_LIBRARIES ${PLANTGL_MATH_LIBRARY} ${PLANTGL_TOOL_LIBRARY} ${PLANTGL_SG_LIBRARY} ${PLANTGL_ALGO_LIBRARY} ${PLANTGL_GUI_LIBRARY})

# Build with PlantGL
set(PLANTGL_INCLUDE_DIRS ${PLANTGL_INCLUDE_DIR})
set(PLANTGL_LIBRARY_DIRS ${PLANTGL_LIBRARY_DIR})
include_directories(${PLANTGL_INCLUDE_DIRS})
link_directories(${PLANTGL_LIBRARY_DIRS})



elseif (NOT PlantGL_FIND_REQUIRED)
message(STATUS "Building without PlantGL - Library not found.")
endif()


# Set PLANTGL_FOUND based only on header location and version.
# It will be updated below for component libraries.
if(PLANTGL_FOUND)
if(PGL_DEBUG)
message(STATUS "location of plantgl/version.h: ${PLANTGL_INCLUDE_DIR}/plantgl/version.h")
endif()

# Extract PGL_VERSION from version.h
set(PGL_VERSION 0)
file(STRINGS "${PLANTGL_INCLUDE_DIR}/plantgl/version.h" _PGL_VERSION_HPP_CONTENTS REGEX "#define PGL_VERSION 0x")
set(_PGL_VERSION_REGEX "([0-9]+)")
if("${_PGL_VERSION_HPP_CONTENTS}" MATCHES ".*#define PGL_VERSION 0x${_PGL_VERSION_REGEX}.*")
set(PGL_VERSION "${CMAKE_MATCH_1}")
endif()
unset(_PGL_VERSION_HPP_CONTENTS)

math(EXPR PGL_MAJOR_VERSION "${PGL_VERSION} / 10000")
math(EXPR PGL_MINOR_VERSION "${PGL_VERSION} / 100 % 100")
math(EXPR PGL_SUBMINOR_VERSION "${PGL_VERSION} % 100")

set(PGL_ERROR_REASON
"${PGL_ERROR_REASON}PlantGL version: ${PGL_MAJOR_VERSION}.${PGL_MINOR_VERSION}.${PGL_SUBMINOR_VERSION}\nPlantGL include path: ${PLANTGL_INCLUDE_DIR}")
message(STATUS "version.h reveals plantgl "
"${PGL_MAJOR_VERSION}.${PGL_MINOR_VERSION}.${PGL_SUBMINOR_VERSION}")
set(PGL_FOUND ON)

else()
set(PGL_FOUND OFF)
set(PGL_ERROR_REASON
"${PGL_ERROR_REASON}Unable to find the PlantGL header files. Please set PGL_INCLUDEDIR to the directory containing PlantGL's headers.")
endif()
11 changes: 11 additions & 0 deletions cmake/FindPython.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
find_package(Python3 COMPONENTS Development REQUIRED)

if (Python3_FOUND)
if (Python3_VERSION_MINOR LESS 6)
message(SEND_ERROR "Python 3.6 or greater is required.")
else()
include_directories(${Python3_INCLUDE_DIRS})
endif()

set(BOOST_PYTHON_LIB "python3${Python3_VERSION_MINOR}")
endif()
Loading

0 comments on commit da1d4f4

Please sign in to comment.