Skip to content

Commit

Permalink
Cleaning up some CMake stuff.
Browse files Browse the repository at this point in the history
  • Loading branch information
jbt committed Sep 24, 2012
1 parent 8b2cef9 commit 49aa9bf
Show file tree
Hide file tree
Showing 6 changed files with 105 additions and 50 deletions.
102 changes: 66 additions & 36 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,14 @@ PROJECT(GoTools)

CMAKE_MINIMUM_REQUIRED(VERSION 2.8)


# Set version info
SET(GoTools_VERSION_MAJOR 4)
SET(GoTools_VERSION_MINOR 0)
SET(GoTools_VERSION_PATCH 1)
SET(GoTools_VERSION "${GoTools_VERSION_MAJOR}.${GoTools_VERSION_MINOR}.${GoTools_VERSION_PATCH}")


# Generate header with version info
CONFIGURE_FILE(gotools-core/include/GoTools/geometry/GoTools_version.h.in
${PROJECT_SOURCE_DIR}/gotools-core/include/GoTools/geometry/GoTools_version.h @ONLY)
Expand All @@ -16,41 +19,45 @@ CONFIGURE_FILE(gpl/fixupdebs.sh.in
CONFIGURE_FILE(gpl/generate_gpl_headers.in
${PROJECT_SOURCE_DIR}/gpl/generate_gpl_headers @ONLY)

ENABLE_LANGUAGE(CXX)

# Set various compiler flags
ENABLE_LANGUAGE(CXX)
IF(NOT WIN32)
# Set warning level to '-Wall' on Linux
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wconversion -Wno-unused-but-set-variable -fPIC")
ELSE(NOT WIN32)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP8 /DNOMINMAX /DNOCRYPT
-D_SCL_SECURE_NO_WARNINGS -D_CRT_SECURE_NO_WARNINGS")
ENDIF(NOT WIN32)

# Get rid of MESSAGEs in Release mode
SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -DNVERBOSE")

OPTION(GoTools_USE_BOOST
"Use BOOST instead of c++0x?" OFF)

OPTION(GoTools_COMPILE_APPS
"Compile applications?" ON)
IF(GoTools_USE_BOOST)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DUSE_BOOST=1")
FIND_PACKAGE(Boost REQUIRED)
INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIRS})
ELSE(GoTools_USE_BOOST)
INCLUDE(CheckCXXCompilerFlag)
IF(CMAKE_CXX_COMPILER_ID MATCHES GNU)
# check if compiler supports c++-0x
CHECK_CXX_COMPILER_FLAG("-std=gnu++0x" HAVE_0x)
IF(HAVE_0x)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++0x")
ELSE(HAVE_0x)
MESSAGE(FATAL_ERROR "A compiler with c++-0x support is needed")
ENDIF(HAVE_0x)
ENDIF(CMAKE_CXX_COMPILER_ID MATCHES GNU)
ENDIF(GoTools_USE_BOOST)
# Check if Boost is available
SET(Boost_ADDITIONAL_VERSIONS "1.47" "1.47.0")
FIND_PACKAGE(Boost)
IF(Boost_FOUND)
MESSAGE("Boost is available")
ENDIF(Boost_FOUND)


# Check if compiler supports c++-0x
INCLUDE(CheckCXXCompilerFlag)
IF(CMAKE_CXX_COMPILER_ID MATCHES GNU)
CHECK_CXX_COMPILER_FLAG("-std=gnu++0x" HAVE_0x)
IF(HAVE_0x)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++0x")
ELSE(HAVE_0x)
# C++0x is not supported - check for Boost?
IF(Boost_FOUND)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DUSE_BOOST=1")
INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIRS})
ELSE(Boost_FOUND)
MESSAGE(FATAL_ERROR "Either Boost or a compiler with c++0x support is needed")
ENDIF(Boost_FOUND)
ENDIF(HAVE_0x)
ENDIF(CMAKE_CXX_COMPILER_ID MATCHES GNU)



# Set install prefix on Windows
Expand All @@ -59,19 +66,32 @@ IF(WIN32)
SET(GoTools_INSTALL_PREFIX "$ENV{PROGRAMFILES}/SINTEF/GoTools"
CACHE PATH "Path to install GoTools")
ENDIF(WIN32)


# Organize the project in folders (VS only?)
SET_PROPERTY(GLOBAL PROPERTY USE_FOLDERS ON)

# For newmat/sisl/ttl to know they are compiled as modules

# For newmat/sisl/ttl to know they are compiled as modules
SET(GoTools_ALL_COMPILE 1)


# Compile apps and examples
OPTION(GoTools_COMPILE_APPS
"Compile applications?" ON)


# Compile unit test - depends on Boost
IF(Boost_FOUND)
OPTION(GoTools_COMPILE_TESTS
"Compile unit tests?" ON)
IF(GoTools_COMPILE_TESTS)
ENABLE_TESTING()
ENDIF(GoTools_COMPILE_TESTS)
ENDIF(Boost_FOUND)


# Comment out the modules you don't want to build

OPTION(GoTools_COMPILE_GPL
OPTION(GoTools_COMPILE_GPL_MODULES_ONLY
"Compile the GPL modules only?" OFF)

ADD_SUBDIRECTORY(newmat)
Expand Down Expand Up @@ -136,33 +156,43 @@ ENDIF(GoTools_COMPILE_MODULE_trivariatemodel)

OPTION(GoTools_COMPILE_MODULE_qualitymodule
"Compile the GoTools module qualitymodule?" ON)
IF(GoTools_COMPILE_MODULE_qualitymodule AND NOT GoTools_COMPILE_GPL)
IF(GoTools_COMPILE_MODULE_qualitymodule
AND NOT GoTools_COMPILE_GPL_MODULES_ONLY)
ADD_SUBDIRECTORY(qualitymodule)
ENDIF(GoTools_COMPILE_MODULE_qualitymodule AND NOT GoTools_COMPILE_GPL)
ENDIF(GoTools_COMPILE_MODULE_qualitymodule
AND NOT GoTools_COMPILE_GPL_MODULES_ONLY)

OPTION(GoTools_COMPILE_MODULE_model_toolbox
"Compile the GoTools modulemodel_toolbox ?" ON)
IF(GoTools_COMPILE_MODULE_model_toolbox AND NOT GoTools_COMPILE_GPL)
IF(GoTools_COMPILE_MODULE_model_toolbox
AND NOT GoTools_COMPILE_GPL_MODULES_ONLY)
ADD_SUBDIRECTORY(model_toolbox)
ENDIF(GoTools_COMPILE_MODULE_model_toolbox AND NOT GoTools_COMPILE_GPL)
ENDIF(GoTools_COMPILE_MODULE_model_toolbox
AND NOT GoTools_COMPILE_GPL_MODULES_ONLY)

OPTION(GoTools_COMPILE_MODULE_isogeometric_model
"Compile the GoTools module isogeometric_model?" ON)
IF(GoTools_COMPILE_MODULE_isogeometric_model AND NOT GoTools_COMPILE_GPL)
IF(GoTools_COMPILE_MODULE_isogeometric_model
AND NOT GoTools_COMPILE_GPL_MODULES_ONLY)
ADD_SUBDIRECTORY(isogeometric_model)
ENDIF(GoTools_COMPILE_MODULE_isogeometric_model AND NOT GoTools_COMPILE_GPL)
ENDIF(GoTools_COMPILE_MODULE_isogeometric_model
AND NOT GoTools_COMPILE_GPL_MODULES_ONLY)

OPTION(GoTools_COMPILE_MODULE_lr_splines
"Compile the GoTools module lr_splines? Depends on Boost." OFF)
IF(GoTools_COMPILE_MODULE_lr_splines AND NOT GoTools_COMPILE_GPL)
IF(GoTools_COMPILE_MODULE_lr_splines
AND NOT GoTools_COMPILE_GPL_MODULES_ONLY)
ADD_SUBDIRECTORY(lr_splines)
ENDIF(GoTools_COMPILE_MODULE_lr_splines AND NOT GoTools_COMPILE_GPL)
ENDIF(GoTools_COMPILE_MODULE_lr_splines
AND NOT GoTools_COMPILE_GPL_MODULES_ONLY)

OPTION(GoTools_COMPILE_MODULE_geometric_modeler
"Compile the GoTools module geometric_modeler? " OFF)
IF(GoTools_COMPILE_MODULE_geometric_modeler AND NOT GoTools_COMPILE_GPL)
IF(GoTools_COMPILE_MODULE_geometric_modeler
AND NOT GoTools_COMPILE_GPL_MODULES_ONLY)
ADD_SUBDIRECTORY(geometric_modeler)
ENDIF(GoTools_COMPILE_MODULE_geometric_modeler AND NOT GoTools_COMPILE_GPL)
ENDIF(GoTools_COMPILE_MODULE_geometric_modeler
AND NOT GoTools_COMPILE_GPL_MODULES_ONLY)

IF(WIN32)
OPTION(GoTools_COMPILE_MODULE_step_reader
Expand Down
22 changes: 21 additions & 1 deletion gotools-core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ SET_PROPERTY(TARGET GoToolsCore
PROPERTY FOLDER "GoToolsCore/Libs")


# Apps, examples, tests, ...?
# Apps and examples
IF(GoTools_COMPILE_APPS)
FILE(GLOB_RECURSE gotools_APPS app/*.C)
FOREACH(app ${gotools_APPS})
Expand All @@ -44,6 +44,26 @@ IF(GoTools_COMPILE_APPS)
ENDFOREACH(app)
ENDIF(GoTools_COMPILE_APPS)


# Unit tests
IF(GoTools_COMPILE_TESTS)
SET(Boost_USE_STATIC_LIBS ON)
FIND_PACKAGE(Boost REQUIRED COMPONENTS unit_test_framework)
INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIRS})
FILE(GLOB_RECURSE gotools_TESTS test/*.C)
FOREACH(test ${gotools_TESTS})
GET_FILENAME_COMPONENT(testname ${test} NAME_WE)
ADD_EXECUTABLE(${testname} ${test})
TARGET_LINK_LIBRARIES(${testname} GoToolsCore ${Boost_LIBRARIES})
# SET_TARGET_PROPERTIES(${testname}
# PROPERTIES RUNTIME_OUTPUT_DIRECTORY test)
SET_PROPERTY(TARGET ${testname}
PROPERTY FOLDER "GoToolsCore/Tests")
ADD_TEST(${testname} ${EXECUTABLE_OUTPUT_PATH}/${testname})
ENDFOREACH(test)
ENDIF(GoTools_COMPILE_TESTS)


# Copy data
ADD_CUSTOM_COMMAND(
TARGET GoToolsCore
Expand Down
4 changes: 4 additions & 0 deletions gotools-core/include/GoTools/utils/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,16 @@ using boost::const_pointer_cast;
using boost::static_pointer_cast;
#include <boost/static_assert.hpp>
#define static_assert(x, msg) BOOST_STATIC_ASSERT(x)
#include <boost/type_traits.hpp>
using boost::is_floating_point;
#else
#include <memory>
using std::shared_ptr;
using std::dynamic_pointer_cast;
using std::const_pointer_cast;
using std::static_pointer_cast;
#include <type_traits>
using std::is_floating_point;
#endif

#endif // _CONFIG_H
4 changes: 2 additions & 2 deletions gpl/fixupdebs.sh.in
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ function Unpack() {

function Pack() {
sed '/^$/d' -i control
if [ "$(Enabled '@GoTools_COMPILE_GPL@')" == "1" ]; then
if [ "$(Enabled '@GoTools_COMPILE_GPL_MODULES_ONLY@')" == "1" ]; then
@PROJECT_SOURCE_DIR@/gpl/generate_gpl_headers ..
fi
cd ../..
Expand Down Expand Up @@ -261,7 +261,7 @@ if [ "$(Enabled '@GoTools_COMPILE_MODULE_trivariatemodel@')" == "1" ]; then
Remove $path/libgotools_${version}_$arch-$code-trivariatemodel-dev.deb
fi

if [ "$(Enabled '@GoTools_COMPILE_GPL@')" == "0" ]; then
if [ "$(Enabled '@GoTools_COMPILE_GPL_MODULES_ONLY@')" == "0" ]; then
# qualitymodule
if [ "$(Enabled '@GoTools_COMPILE_MODULE_qualitymodule@')" == "1" ]; then
Unpack $path/libgotools_${version}_$arch-$code-qualitymodule.deb
Expand Down
14 changes: 7 additions & 7 deletions viewlib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ PROJECT(viewlib)

FIND_PACKAGE(OpenGL REQUIRED)
FIND_PACKAGE(Qt4 REQUIRED)
SET(Boost_ADDITIONAL_VERSIONS
"1.42" "1.42.0"
"1.43" "1.43.0"
"1.44" "1.44.0"
"1.47" "1.47.0")
FIND_PACKAGE(Boost REQUIRED)
#SET(Boost_ADDITIONAL_VERSIONS
# "1.42" "1.42.0"
# "1.43" "1.43.0"
# "1.44" "1.44.0"
# "1.47" "1.47.0")
#FIND_PACKAGE(Boost REQUIRED)


IF(WIN32)
Expand Down Expand Up @@ -51,7 +51,7 @@ INCLUDE_DIRECTORIES(
${QT_INCLUDES}
${OPENGL_INCLUDE_DIR}
${GLUT_INCLUDE_DIR}
${Boost_INCLUDE_DIR}
# ${Boost_INCLUDE_DIR}
)


Expand Down
9 changes: 5 additions & 4 deletions viewlib/include/GoTools/viewlib/gvColor.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@
#define _GVCOLOR_H


#include <boost/type_traits.hpp>
//#include <boost/type_traits.hpp>
#include <cmath>
#include "GoTools/utils/config.h"

/// Represents a color by four floats, like in OpenGL.
struct gvColor
Expand All @@ -31,14 +32,14 @@ struct gvColor
template <typename NumericType>
gvColor(NumericType r, NumericType g, NumericType b)
{
setVal(Int2Type< boost::is_floating_point<NumericType>::value >(),
setVal(Int2Type< is_floating_point<NumericType>::value >(),
r, g, b);
}
template <typename NumericType>
gvColor(NumericType r, NumericType g, NumericType b,
NumericType alpha)
{
setVal(Int2Type< boost::is_floating_point<NumericType>::value >(),
setVal(Int2Type< is_floating_point<NumericType>::value >(),
r, g, b, alpha);
}

Expand All @@ -47,7 +48,7 @@ struct gvColor
NumericType alpha)
{
gvColor ret;
ret.setHsva(Int2Type< boost::is_floating_point<NumericType>::value >(),
ret.setHsva(Int2Type< is_floating_point<NumericType>::value >(),
h, s, v, alpha);
return ret;
}
Expand Down

0 comments on commit 49aa9bf

Please sign in to comment.