CMakeLists.txt 18.2 KB
Newer Older
1
CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
wiebel's avatar
wiebel committed
2
PROJECT( OpenWalnut )
3

Mathias Goldau's avatar
[ADD]  
Mathias Goldau committed
4 5
# append search path for FindModules:
#------------------------------------
6
LIST( APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/../tools/CMakeModules )
Mathias Goldau's avatar
[ADD]  
Mathias Goldau committed
7 8
# include custom CMake commands like assert
INCLUDE( ${PROJECT_SOURCE_DIR}/../tools/CMakeModules/Utils.cmake )
9

10 11 12 13 14
# mimic layout of install dir for build:
#----------------------------------------
SET( CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin )
SET( CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib )
SET( CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib )
15
SET( SHARED_FILES_RELATIVE "../share/${CMAKE_PROJECT_NAME}" CACHE INTERNAL "Relative path to bin/ denoting the destination for shaders and cfg files." )  # this path us the relative path to bin/ used for all shared files like shaders and config file
16 17 18 19 20 21 22

# CMAKE automatism to select static vs. shared building:
#-------------------------------------------------------
IF( NOT CMAKE_GENERATOR MATCHES "Visual Studio" )
  OPTION( BUILD_SHARED_LIBS "Build shared libs" ON )
  MARK_AS_ADVANCED( BUILD_SHARED_LIBS )
ENDIF()
23

Mathias Goldau's avatar
[ADD]  
Mathias Goldau committed
24 25
# platform dependend stuff:
#--------------------------
26
IF( CMAKE_GENERATOR MATCHES "Visual Studio" )
27
  INCLUDE_DIRECTORIES( "${PROJECT_SOURCE_DIR}/common/platformDependent/visualStudio/" )
Mathias Goldau's avatar
[ADD]  
Mathias Goldau committed
28
ENDIF()
wiebel's avatar
wiebel committed
29

30

31
# Package dependencies:
Mathias Goldau's avatar
[ADD]  
Mathias Goldau committed
32
#----------------------
33
### BOOST ###
34 35 36 37
IF( CMAKE_GENERATOR MATCHES "Visual Studio" )
  SET( Boost_USE_STATIC_LIBS ON )
ENDIF()

38
SET( Boost_USE_MULTITHREAD ON )
39

40 41
# To see which boost libs we currently use, you may run the following command
# in the trunk/src directory on a linux box to make some investigations:
42
# grep -i include `find . -type f` | grep boost | awk '{print $2}' | sort | uniq
43
FIND_PACKAGE( Boost REQUIRED program_options thread filesystem date_time system signals regex )
cornimueller's avatar
cornimueller committed
44
ASSERT_GE_VERSION( "Boost" "${Boost_MAJOR_VERSION}.${Boost_MINOR_VERSION}.${Boost_SUBMINOR_VERSION}" 1.39.0 )
Mathias Goldau's avatar
[ADD]  
Mathias Goldau committed
45
INCLUDE_DIRECTORIES( ${Boost_INCLUDE_DIR} )
46 47 48 49 50

### OpenGL ###
FIND_PACKAGE( OpenGL REQUIRED )

### CxxTest ###
wiebel's avatar
wiebel committed
51
FIND_PACKAGE( CxxTest QUIET )
Mathias Goldau's avatar
[ADD]  
Mathias Goldau committed
52
MARK_AS_ADVANCED( CXXTEST_PERL_TESTGEN_EXECUTABLE )
53
OPTION( OW_USE_TESTS "This enables compilation of tests" ON )
54 55 56 57 58 59 60 61 62 63 64
IF( CXXTEST_FOUND )
  INCLUDE_DIRECTORIES( ${CXXTEST_INCLUDE_DIR} )
  IF( OW_USE_TESTS )
    SET( OW_COMPILE_TESTS ON ) #We need this variable because this is tested more often.
    # Package settings:
    SET( CXXTEST_USE_PYTHON 1 )
    # Activate CTest and "test" target
    ENABLE_TESTING()
  ELSE()
    SET( OW_COMPILE_TESTS OFF )
  ENDIF()
65 66 67
ELSE()
  SET( OW_COMPILE_TESTS OFF )
ENDIF()
wiebel's avatar
wiebel committed
68

Mathias Goldau's avatar
[ADD]  
Mathias Goldau committed
69 70
### OpenSceneGraph ###
SET( MIN_OSG_VERSION 2.8.0 )
71 72 73 74 75 76 77 78
IF( NOT CMAKE_GENERATOR MATCHES "Visual Studio" )
  FIND_PACKAGE( osg ${MIN_OSG_VERSION} REQUIRED )
  FIND_PACKAGE( osgUtil ${MIN_OSG_VERSION} REQUIRED )
  FIND_PACKAGE( osgDB ${MIN_OSG_VERSION} REQUIRED )
  FIND_PACKAGE( osgViewer ${MIN_OSG_VERSION} REQUIRED )
  FIND_PACKAGE( osgText ${MIN_OSG_VERSION} REQUIRED )
  FIND_PACKAGE( osgGA ${MIN_OSG_VERSION} REQUIRED )
  FIND_PACKAGE( osgSim ${MIN_OSG_VERSION} REQUIRED )
79
  FIND_PACKAGE( osgWidget ${MIN_OSG_VERSION} REQUIRED )
80
  FIND_PACKAGE( OpenThreads ${MIN_OSG_VERSION} REQUIRED )
81 82
  SET( OPENSCENEGRAPH_LIBRARIES ${OSGDB_LIBRARY} ${OSGTEXT_LIBRARY} ${OSGGA_LIBRARY} ${OSGUTIL_LIBRARY} ${OSGVIEWER_LIBRARY} ${OSG_LIBRARY} ${OSGSIM_LIBRARY} ${OSGWIDGET_LIBRARY} ${OPENTHREADS_LIBRARY} )
  SET( OPENSCENEGRAPH_INCLUDE_DIRS ${OSG_INCLUDE_DIR} ${OSGDB_INCLUDE_DIR} ${OSGTEXT_INCLUDE_DIR} ${OSGGA_INCLUDE_DIR} ${OSGVIEWER_INCLUDE_DIR} ${OSGUTIL_INCLUDE_DIR} ${OSGSIM_INCLUDE_DIR} ${OSGWIDGET_INCLUDE_DIR} ${OPENTHREADS_INCLUDE_DIR} )
83 84 85 86 87 88 89
  # When new cmake version available >=2.6.4 we may use this the line below instead the stuff above
  # FIND_PACKAGE( OpenSceneGraph 2.8.0 REQUIRED osgDB osgUtil osgGA osgViewer osgSim OpenThreads )
  INCLUDE_DIRECTORIES( ${OPENSCENEGRAPH_INCLUDE_DIRS} )
ELSE()
  IF( NOT VERSION LESS 2.6.3 )
    SET ( CMAKE_PREFIX_PATH "$ENV{ProgramFiles}/OpenSceneGraph" )
  ENDIF()
90
  FIND_PACKAGE( OpenSceneGraph ${MIN_OSG_VERSION} REQUIRED osgUtil osgDB osgViewer osgText osgGA osgSim osgWidget )
91 92
  INCLUDE_DIRECTORIES( ${OPENSCENEGRAPH_INCLUDE_DIRS} )
ENDIF()
Mathias Goldau's avatar
[ADD]  
Mathias Goldau committed
93

94
# some modules need the teem library (http://teem.sourceforge.net/)
95 96 97 98 99 100
find_package( Teem PATHS /usr/local/lib /opt/teem/lib QUIET )
IF( Teem_FOUND )    # we need to add the include path and lib path to allow the compiler and linker to find teem even if it was not installed to
                    # /usr/local
    INCLUDE_DIRECTORIES( ${Teem_INCLUDE_DIRS} )
    LINK_DIRECTORIES( ${LINK_DIRECTORIES} ${Teem_LIBRARY_DIRS} )
ENDIF()
101

102 103 104 105 106 107 108 109 110 111 112 113 114 115
### OSSIM ###
FIND_PACKAGE( OSSIM QUIET )
IF( OSSIM_FOUND )
  MESSAGE( STATUS "Found OSSIM." )
  ADD_DEFINITIONS( -DUSEOSSIM )
  INCLUDE_DIRECTORIES( ${OSSIM_INCLUDE_DIR} )
  LINK_LIBRARIES( ${OSSIM_LIBRARY} )
# TODO(math): is an entry in link directories necessary?
#   LINK_DIRECTORIES( ${OSSIM_LIBDIR} )
  MARK_AS_ADVANCED( OSSIM_INCLUDEDIR )
  MARK_AS_ADVANCED( OSSIM_LIBRARIES )
#   MARK_AS_ADVANCED( OSSIM_LIBDIR )
ENDIF()

116 117 118 119 120 121 122
# insight toolkit (for image segmentation and registration)
#----------------------------------------------------------
FIND_PACKAGE( ITK QUIET )
OPTION( OW_USE_ITK "Use the insight toolkit for image segmentation" OFF )
IF( ITK_FOUND AND OW_USE_ITK )
	INCLUDE( ${ITK_USE_FILE} )
ENDIF( ITK_FOUND AND OW_USE_ITK )
123

124
### Eigen #### (for the gauss process, the covariance matrices tend to be sparse and 20x20, but ~70.000 of them)
125 126 127 128 129
FIND_PACKAGE( Eigen3 QUIET )
IF( EIGEN3_FOUND )
    MESSAGE( STATUS "Found Eigen3 in: ${EIGEN3_INCLUDE_DIR} with version: ${EIGEN3_VERSION}" )
    MARK_AS_ADVANCED( EIGEN3_INCLUDE_DIR )
    MARK_AS_ADVANCED( EIGEN3_VERSION )
130 131
ENDIF()

Mathias Goldau's avatar
[ADD]  
Mathias Goldau committed
132 133 134 135
# other options:
#---------------
# Set default build type
IF( NOT CMAKE_BUILD_TYPE )
136
    SET( CMAKE_BUILD_TYPE Release
137
         CACHE STRING "Choose the type of build, options are: Debug Release RelWithDebInfo"
Mathias Goldau's avatar
[ADD]  
Mathias Goldau committed
138 139 140 141 142 143
         FORCE
       )
ENDIF( NOT CMAKE_BUILD_TYPE )
SET( EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin CACHE PATH "The executables will be put into this directory." )
MARK_AS_ADVANCED( LIBRARY_OUTPUT_PATH )
MARK_AS_ADVANCED( EXECUTABLE_OUTPUT_PATH )
144

145
# Global compiler flags:
Mathias Goldau's avatar
[ADD]  
Mathias Goldau committed
146
#-----------------------
147 148
# -Wno-long-long    since on Ubuntu 8.10 it won't compile without it
# -ansi             force ISO-C++98 compliance (not GNU++98)
149

150
IF( CMAKE_GENERATOR MATCHES "Visual Studio" )
151
    FILE( GLOB EXCLUDE_LIBRARIES RELATIVE ${Boost_LIBRARY_DIRS} ${Boost_LIBRARY_DIRS}/libboost* )
152 153
    SET( CMAKE_SHARED_LINKER_FLAGS " /STACK:10000000 /machine:I386 /NODEFAULTLIB:${EXCLUDE_LIBRARIES}"  CACHE STRING "" FORCE )
    SET( CMAKE_EXE_LINKER_FLAGS " /STACK:10000000 /machine:I386 /NODEFAULTLIB:${EXCLUDE_LIBRARIES}"  CACHE STRING "" FORCE )
154
    SET( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D \"NOMINMAX\"" )
155 156
    SET( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP" )
	SET( CMAKE_DEBUG_POSTFIX "d" CACHE STRING "add a postfix, usually d on windows" )
157
ELSE()
158 159 160 161
    # Unfortunately libstdc++'s header files don't work with mingw in ansi mode (basically libstdc++'s fault)
    IF( CMAKE_HOST_SYSTEM MATCHES "Windows" )
        SET( CMAKE_CXX_FLAGS "-frtti -pedantic -Wall -Wno-long-long -Wextra -Wold-style-cast" CACHE STRING "" FORCE )
    ELSE()
162 163
        # SET( CMAKE_CXX_FLAGS "-frtti -pedantic -ansi -Wall -Wno-long-long -Wextra -Wold-style-cast" CACHE STRING "" FORCE )
        SET( CMAKE_CXX_FLAGS "-frtti -pedantic -ansi -Wall -Wno-long-long -Wextra " CACHE STRING "" FORCE )
164 165 166 167
    ENDIF()

    # Darwin's ld isn't GNU and doesn't like the following
    IF( NOT CMAKE_SYSTEM_NAME MATCHES "Darwin" )
168 169
        ## The following allows us to prevent cyclic dependencies even on linux
        SET( CMAKE_SHARED_LINKER_FLAGS "-Wl,--no-undefined -Wl,--allow-shlib-undefined" CACHE STRING "" FORCE )
170
    ENDIF()
171
    SET( CMAKE_CXX_FLAGS_RELEASE "-O3" CACHE STRING "" FORCE )
172
    SET( CMAKE_CXX_FLAGS_DEBUG "-g -DDEBUG -O0" CACHE STRING "" FORCE )
173 174
ENDIF()

175 176 177 178 179
IF( ITK_FOUND AND OW_USE_ITK )
	SET( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DOW_USE_ITK" CACHE STRING "" FORCE )
	SET( CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DOW_USE_ITK" CACHE STRING "" FORCE )
ENDIF( ITK_FOUND AND OW_USE_ITK )

180 181
SET( CMAKE_CXX_FLAGS_RELWITHDEBINFO "-g -DDEBUG -O2" CACHE STRING "" FORCE )

182 183 184 185 186 187
ADD_SUBDIRECTORY( dataHandler )
ADD_SUBDIRECTORY( graphicsEngine )
ADD_SUBDIRECTORY( gui )
ADD_SUBDIRECTORY( kernel )
ADD_SUBDIRECTORY( common )
ADD_SUBDIRECTORY( modules )
188
ADD_SUBDIRECTORY( ext ) # The needed external libraries
189 190 191

#-------------------------------------------------------------------------------------------------------------
# Writes information about the revision of the current code to the file version.h which then gets included by OpenWalnut.cpp
192 193 194 195 196 197 198 199 200 201 202 203 204 205 206
IF( NOT CMAKE_GENERATOR MATCHES "Visual Studio" )
	add_custom_command( OUTPUT ${PROJECT_SOURCE_DIR}/version.h
						MAIN_DEPENDENCY ${PROJECT_SOURCE_DIR}/../.hg/dirstate
						COMMAND hg parents --template '\#define W_VERSION \"{node|short} {rev} {branches} {tags}\"' > ${PROJECT_SOURCE_DIR}/version.h
						WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
						COMMENT "Creating version.h"
					 )
ELSE()
	add_custom_command( OUTPUT ${PROJECT_SOURCE_DIR}/version.h
						MAIN_DEPENDENCY ${PROJECT_SOURCE_DIR}/../.hg/dirstate
						COMMAND hg parents --template "\"#define W_VERSION \"\"{node|short} {rev} {branches} {tags}\"\"\"" > ${PROJECT_SOURCE_DIR}/version.h
						WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
						COMMENT "Creating version.h"
					 )
ENDIF()
207 208 209 210

# finally, build walnut
ADD_EXECUTABLE( walnut OpenWalnut.cpp version.h )
TARGET_LINK_LIBRARIES( walnut OWkernel OWdataHandler OWgui OWguiqt4 OWcommon OWge ${Boost_LIBRARIES} )
211

212 213 214 215 216
IF(MSVC_IDE)
	SET_TARGET_PROPERTIES( walnut PROPERTIES DEBUG_POSTFIX "d")
	SET_TARGET_PROPERTIES( walnut PROPERTIES PREFIX "../")    
ENDIF(MSVC_IDE)

217 218 219 220 221
#---------- Shaders -------------
option( OW_COPY_SHADERS "This enables copying shaders with every make call." ON )
if( OW_COPY_SHADERS )
  add_custom_target( shaderDirectoryConfiguration
    ALL
222
    COMMAND ${CMAKE_COMMAND} -D OW_SOURCE_DIR:STRING=${PROJECT_SOURCE_DIR} -D SHARED_FILES_RELATIVE:PATH=${SHARED_FILES_RELATIVE} -P ${PROJECT_SOURCE_DIR}/../tools/CMakeModules/UpdateShaders.cmake
223
    COMMENT "Put all global shaders to the right place or update them if they are already there."
224 225
    )
endif( OW_COPY_SHADERS )
226

227 228 229
#---------- fonts -------------
add_custom_target( fontsDirectoryConfiguration
  ALL
230
  COMMAND ${CMAKE_COMMAND} -D OW_SOURCE_DIR:STRING=${PROJECT_SOURCE_DIR} -D SHARED_FILES_RELATIVE:PATH=${SHARED_FILES_RELATIVE} -P ${PROJECT_SOURCE_DIR}/../tools/CMakeModules/CopyFonts.cmake
231 232
  COMMENT "Put all fonts to the right place."
  )
233

234
#---------- shell scripts -------------
235 236 237 238 239
IF( CMAKE_GENERATOR MATCHES "Visual Studio" )
  add_custom_target( binDirectoryConfiguration
    ALL
    COMMAND ${CMAKE_COMMAND} -D OW_SOURCE_DIR:STRING=${PROJECT_SOURCE_DIR} -P ${PROJECT_SOURCE_DIR}/../tools/CMakeModules/CopyShellScriptsWin.cmake
    COMMENT "Put all shell scripts to the right place."
240
  )
241 242 243 244 245 246 247
ELSE()
  add_custom_target( binDirectoryConfiguration
    ALL
    COMMAND ${CMAKE_COMMAND} -D OW_SOURCE_DIR:STRING=${PROJECT_SOURCE_DIR} -P ${PROJECT_SOURCE_DIR}/../tools/CMakeModules/CopyShellScripts.cmake
    COMMENT "Put all shell scripts to the right place."
  )
ENDIF()
248

249
#---------- walnut.cfg file -------------
250 251 252
IF( NOT EXISTS ${PROJECT_BINARY_DIR}/bin/${SHARED_FILES_RELATIVE}/walnut.cfg )
  CONFIGURE_FILE( ${PROJECT_SOURCE_DIR}/../doc/user/walnut.cfg.mpi ${PROJECT_BINARY_DIR}/bin/${SHARED_FILES_RELATIVE}/walnut.cfg COPYONLY )
  MESSAGE( STATUS "Copied ${PROJECT_SOURCE_DIR}/../doc/user/walnut.cfg.mpi to ${PROJECT_BINARY_DIR}/bin/${SHARED_FILES_RELATIVE}/walnut.cfg" )
253 254
ENDIF()

255
# Special targets:
256
#-------------------------------------------------------------------------------------------------------------
257
# Creates API via Doxygen
Mathias Goldau's avatar
[ADD]  
Mathias Goldau committed
258 259 260 261 262 263 264
ADD_CUSTOM_TARGET( doc
                   COMMAND doxygen ${PROJECT_SOURCE_DIR}/../doc/developer/doxygenConfig
                   COMMAND chmod -R g+r ${PROJECT_SOURCE_DIR}/../doc/developer/html
                   WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/..
                   COMMENT "Build doxygen documentation"
                   VERBATIM
                 )
265

266
# NOTE: this full documentation also includes call/caller graphs, colaboration graphs and nicer inheritance graphs
267
# but needs "dot" from graphviz to render them.
268 269
ADD_CUSTOM_TARGET( fulldoc
                   COMMAND doxygen ${PROJECT_SOURCE_DIR}/../doc/developer/doxygenConfigFull
270
                   COMMAND chmod -R g+r ${PROJECT_SOURCE_DIR}/../doc/developer/htmlFull
271
                   WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/..
272
                   COMMENT "Build verbose doxygen documentation"
273 274 275
                   VERBATIM
                 )

Mathias Goldau's avatar
[ADD]  
Mathias Goldau committed
276
#-------------------------------------------------------------------------------------------------------------
ebaum's avatar
[ADD]  
ebaum committed
277
# Uses ctags to create source tags, usable in many editors like VIM or Emacs
Mathias Goldau's avatar
[ADD]  
Mathias Goldau committed
278 279 280 281
ADD_CUSTOM_COMMAND( OUTPUT ctags
                    COMMAND ctags -R --c++-kinds=+p --fields=+iaS --extra=+q .
                    WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/
                    COMMENT "Build ctags tagfile"
ebaum's avatar
[ADD]  
ebaum committed
282 283
                  )

Mathias Goldau's avatar
[ADD]  
Mathias Goldau committed
284
#-------------------------------------------------------------------------------------------------------------
ebaum's avatar
[ADD]  
ebaum committed
285
# Uses cscope to create several source graphs (dependency, call, caller, ...), usable in many editors like VIM or Emacs
Mathias Goldau's avatar
[ADD]  
Mathias Goldau committed
286 287 288 289
ADD_CUSTOM_COMMAND( OUTPUT cscope
                    COMMAND cscope -R -b
                    WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/
                    COMMENT "Build cscope tagfile"
ebaum's avatar
[ADD]  
ebaum committed
290 291
                  )

Mathias Goldau's avatar
[ADD]  
Mathias Goldau committed
292
#-------------------------------------------------------------------------------------------------------------
ebaum's avatar
[ADD]  
ebaum committed
293
# The command "make tags" creates ctags and cscope tag files
Mathias Goldau's avatar
[ADD]  
Mathias Goldau committed
294
ADD_CUSTOM_TARGET( tags DEPENDS ctags DEPENDS cscope )
295

296 297
#-------------------------------------------------------------------------------------------------------------
# Determines the number of cores available on this machine
298 299 300 301 302
IF( NOT CMAKE_GENERATOR MATCHES "Visual Studio" )
	SET( NUM_CORES_SOURCE_DIR ${PROJECT_SOURCE_DIR}/../tools/numCores )
	SET( NUM_CORES_BINARY_DIR ${PROJECT_BINARY_DIR}/numCores )
	SET( NUM_CORES_BINARY ${NUM_CORES_BINARY_DIR}/numCores )
	ADD_CUSTOM_TARGET( numCores
303 304 305 306 307
                   COMMAND ${CMAKE_COMMAND} -E make_directory ${NUM_CORES_BINARY_DIR}
                   COMMAND cd ${NUM_CORES_BINARY_DIR} && ${CMAKE_COMMAND} ${NUM_CORES_SOURCE_DIR} > /dev/null
                   COMMAND $(MAKE) -C ${NUM_CORES_BINARY_DIR} > /dev/null
                   COMMENT "Determines the number of cores available on this machine"
                 )
308
ENDIF()
309

Mathias Goldau's avatar
[ADD]  
Mathias Goldau committed
310
#-------------------------------------------------------------------------------------------------------------
311
# Checks style guide lines via the BrainLint tool against all source code files
312 313
#    The output is colored when variable CMAKE_COLOR_MAKEFILE is set to ON,
#    noncolored if it is set to OFF
314
FILE( GLOB_RECURSE STYLE_CPP ${PROJECT_SOURCE_DIR}/*.cpp )
Mathias Goldau's avatar
[ADD]  
Mathias Goldau committed
315
FILE( GLOB_RECURSE STYLE_H ${PROJECT_SOURCE_DIR}/*.h )
316
FILE( GLOB_RECURSE STYLE_GLSL ${PROJECT_SOURCE_DIR}/*.glsl )
Mathias Goldau's avatar
[ADD]  
Mathias Goldau committed
317
# Set dirs to exclude from stylecheck
Alexander Wiebel's avatar
Alexander Wiebel committed
318
SET( EXCLUDE_DIRS "/ext/nifti/;/dataHandler/io/biosig/;/dataHandler/io/biosigWin/;/dataHandler/io/biosig/XMLParser/;/dataHandler/io/biosigWin/XMLParser/;/ext/libeep/avr/;/ext/libeep/cnt/;/ext/libeep/eep/;/common/platformDependent/visualStudio/;/modules/lic/fibernavigator/;/modules/lic/fantom/" )
319 320
FOREACH( dirname ${EXCLUDE_DIRS} )
    FILE( GLOB EXCLUDE_H   ${PROJECT_SOURCE_DIR}${dirname}*.h )
321
    FILE( GLOB EXCLUDE_CPP ${PROJECT_SOURCE_DIR}${dirname}*.cpp )
322

323
    FOREACH( fname ${EXCLUDE_H} )
324
      LIST( REMOVE_ITEM STYLE_H ${fname} )
325 326 327
    ENDFOREACH( fname )

    FOREACH( fname ${EXCLUDE_CPP} )
Mathias Goldau's avatar
[ADD]  
Mathias Goldau committed
328
        LIST( REMOVE_ITEM STYLE_CPP ${fname} )
329 330
    ENDFOREACH( fname )
ENDFOREACH( dirname )
331
LIST( REMOVE_ITEM STYLE_H ${PROJECT_SOURCE_DIR}/version.h )
332

333
IF( CMAKE_COLOR_MAKEFILE )
334 335 336 337 338 339
    SET( STYLECHECK_OPTIONS "--color" )
ELSE()
    SET( STYLECHECK_OPTIONS "" )
ENDIF()

IF( CMAKE_HOST_WIN32 )
340 341 342
    SET( XARGS_OPTIONS "-n 128" )
ELSEIF( CMAKE_HOST_UNIX )
    SET( XARGS_OPTIONS -P \$\$\(${NUM_CORES_BINARY}\) -n 64 )
Mathias Goldau's avatar
[ADD]  
Mathias Goldau committed
343
ELSE()
344
    SET( XARGS_OPTIONS "" )
Mathias Goldau's avatar
[ADD]  
Mathias Goldau committed
345
ENDIF()
346

347
FILE( WRITE ${PROJECT_BINARY_DIR}/brainlintlist "" )
348
FOREACH( fname ${STYLE_CPP} ${STYLE_H} ${STYLE_GLSL} )
349
    FILE( APPEND ${PROJECT_BINARY_DIR}/brainlintlist "${fname}\n" )
350 351 352
ENDFOREACH()

ADD_CUSTOM_TARGET( stylecheck
353 354 355 356 357
                   COMMAND  cat ${PROJECT_BINARY_DIR}/brainlintlist | xargs ${XARGS_OPTIONS} ${PROJECT_SOURCE_DIR}/../tools/brainlint.py ${STYLECHECK_OPTIONS} 2>&1 | grep -iv 'Total errors found: 0$$' | cat
                   DEPENDS numCores
                   WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
                   COMMENT "Check if code complies to CodingStandard"
                 )
358

359
#-------------------------------------------------------------------------------------------------------------
math's avatar
[ADD]  
math committed
360
# Prints the verbose output of the test runners, so you may identify the source of error early, if any
Mathias Goldau's avatar
[ADD]  
Mathias Goldau committed
361
ADD_CUSTOM_TARGET( vtest
362
                   COMMAND $(MAKE) test ARGS="-V"
Mathias Goldau's avatar
[ADD]  
Mathias Goldau committed
363 364
                   COMMENT "Runs the test in verboseness to see what actually went wrong"
                 )
math's avatar
[ADD]  
math committed
365

366
#-------------------------------------------------------------------------------------------------------------
367
# Checks if all is well to commit (aka commitCheck, cicheck)
Mathias Goldau's avatar
[ADD]  
Mathias Goldau committed
368
ADD_CUSTOM_TARGET( cicheck
369
                   COMMAND $(MAKE) stylecheck && $(MAKE) test && $(MAKE) doc
Mathias Goldau's avatar
[ADD]  
Mathias Goldau committed
370 371
                   COMMENT "Checks if all is well to commit"
                 )
372

wiebel's avatar
wiebel committed
373
#-------------------------------------------------------------------------------------------------------------
374
# Makes many special make targets in combination. Default number of cores is 1.
wiebel's avatar
wiebel committed
375
ADD_CUSTOM_TARGET( many
376
                   COMMAND echo Using \$\$\(${NUM_CORES_BINARY}\) cores.\; $(MAKE) all -j\$\$\(${NUM_CORES_BINARY}\)
377 378 379
                   COMMAND $(MAKE) test
                   COMMAND $(MAKE) stylecheck
                   COMMAND $(MAKE) doc
380
                   DEPENDS numCores
Mathias Goldau's avatar
[ADD]  
Mathias Goldau committed
381 382
                   COMMENT "Make many special make targets in combination."
                 )
383 384 385 386 387

#-------------------------------------------------------------------------------------------------------------
# Make target for MacOS. The difference to the normal one is that we need to fix some paths in libraries.
IF( CMAKE_HOST_SYSTEM MATCHES Darwin )
ADD_CUSTOM_TARGET( macos
388
                   $(MAKE) all && ${PROJECT_SOURCE_DIR}/../tools/MacOS/macOS_install_tool
389 390 391
                   COMMENT "Make on MacOS. This incudes fixing paths in libraries."
                 )
ENDIF()