~verifypn-wf/verifypn/png

213.1.30 by Peter G. Jensen
commit removing old files, swithing to propper CMAKE
1
cmake_minimum_required(VERSION 3.9)
2
cmake_policy(SET CMP0048 NEW)
3
cmake_policy(SET CMP0069 NEW)
4
5
set(CMAKE_CXX_STANDARD 17)
6
if (NOT CMAKE_BUILD_TYPE)
7
        set(CMAKE_BUILD_TYPE Release)
8
endif (NOT CMAKE_BUILD_TYPE)
9
213.1.42 by Peter G. Jensen
switching to glpk instead of lpsolve
10
if (CMAKE_BUILD_TYPE MATCHES Release)
213.1.146 by srba.jiri at gmail
allowed compilation for Mac
11
    if (NOT APPLE)
12
    	set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE)
13
    endif ()
213.1.42 by Peter G. Jensen
switching to glpk instead of lpsolve
14
endif ()
213.1.30 by Peter G. Jensen
commit removing old files, swithing to propper CMAKE
15
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
16
213.1.39 by Peter G. Jensen
more cmake hacking, adding versioning and conditional
17
226 by srba.jiri at gmail
updated version number to 3.1.0
18
set(VERIFYPN_VERSION 3.1.0)
213.1.39 by Peter G. Jensen
more cmake hacking, adding versioning and conditional
19
add_compile_definitions(VERIFYPN_VERSION=\"${VERIFYPN_VERSION}\")
20
21
project(verifypn VERSION ${VERIFYPN_VERSION} LANGUAGES CXX C)
213.1.30 by Peter G. Jensen
commit removing old files, swithing to propper CMAKE
22
213.1.62 by Peter G. Jensen
setting default cmake flags and fixing static
23
option(VERIFYPN_Static "Link libraries statically" ON)
24
option(VERIFYPN_MC_Simplification "Enables multicore simplification, incompatible with static linking" OFF)
213.1.30 by Peter G. Jensen
commit removing old files, swithing to propper CMAKE
25
option(VERIFYPN_GetDependencies "Fetch external dependencies from web." ON)
26
213.1.37 by Peter G. Jensen
better handling in cmake
27
213.1.30 by Peter G. Jensen
commit removing old files, swithing to propper CMAKE
28
if (VERIFYPN_Static)
29
    set(BUILD_SHARED_LIBS OFF)
213.1.37 by Peter G. Jensen
better handling in cmake
30
    if (VERIFYPN_MC_Simplification)
31
        message( FATAL_ERROR "Multicore Simplification is not compatible with static linking" )
213.1.62 by Peter G. Jensen
setting default cmake flags and fixing static
32
    endif(VERIFYPN_MC_Simplification)
213.1.30 by Peter G. Jensen
commit removing old files, swithing to propper CMAKE
33
    if (NOT APPLE)
213.1.62 by Peter G. Jensen
setting default cmake flags and fixing static
34
        set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static")
227 by srba.jiri at gmail
fixed compilation with static libraries for mac
35
    else(NOT APPLE)
36
    	set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static-libgcc -static-libstdc++")
213.1.62 by Peter G. Jensen
setting default cmake flags and fixing static
37
    endif(NOT APPLE)
38
else(VERIFYPN_Static)
39
    set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static-libgcc -static-libstdc++")
213.1.30 by Peter G. Jensen
commit removing old files, swithing to propper CMAKE
40
endif (VERIFYPN_Static)
197.3.20 by Andreas Klostergaard
Added CMake support.
41
213.1.39 by Peter G. Jensen
more cmake hacking, adding versioning and conditional
42
if (VERIFYPN_MC_Simplification)
43
    add_compile_definitions(VERIFYPN_MC_Simplification)
44
endif(VERIFYPN_MC_Simplification)
45
209.1.1 by Andreas Klostergaard
First attempt at improving unfolding
46
if (UNIX AND NOT APPLE)
213.1.30 by Peter G. Jensen
commit removing old files, swithing to propper CMAKE
47
    set(ARCH_TYPE "linux64")
197.3.20 by Andreas Klostergaard
Added CMake support.
48
elseif(APPLE)
213.1.30 by Peter G. Jensen
commit removing old files, swithing to propper CMAKE
49
    set(ARCH_TYPE "osx64")
213.1.146 by srba.jiri at gmail
allowed compilation for Mac
50
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mmacosx-version-min=10.8 -m64 ")
51
    set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -mmacosx-version-min=10.8 -m64 ")
197.3.20 by Andreas Klostergaard
Added CMake support.
52
else()
213.1.30 by Peter G. Jensen
commit removing old files, swithing to propper CMAKE
53
    set(ARCH_TYPE "win64")
197.3.20 by Andreas Klostergaard
Added CMake support.
54
endif ()
55
213.1.117 by Peter G. Jensen
switched to O3 and no pg
56
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -Wall -pedantic-errors -O3 -DNDEBUG")
213.1.30 by Peter G. Jensen
commit removing old files, swithing to propper CMAKE
57
213.1.117 by Peter G. Jensen
switched to O3 and no pg
58
set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} -O3 -DNDEBUG")
213.1.41 by Peter G. Jensen
added missing static compiler flag
59
if (VERIFYPN_Static AND NOT APPLE)
60
    set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} -static")
213.1.42 by Peter G. Jensen
switching to glpk instead of lpsolve
61
endif()
213.1.30 by Peter G. Jensen
commit removing old files, swithing to propper CMAKE
62
63
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
64
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
65
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
66
67
if (VERIFYPN_GetDependencies)
68
    # setup for external imports
69
    include(ExternalProject)
70
    set(EXTERNAL_INSTALL_LOCATION ${CMAKE_BINARY_DIR}/external)
71
213.1.35 by Peter G. Jensen
using ptries from official distribution-chan
72
    ExternalProject_add(ptrie-ext
73
        GIT_REPOSITORY https://github.com/petergjoel/ptrie
213.1.37 by Peter G. Jensen
better handling in cmake
74
        GIT_TAG 230b3640bfbe2ed5befdafbaf17bd3804231b50f
213.1.35 by Peter G. Jensen
using ptries from official distribution-chan
75
        CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${EXTERNAL_INSTALL_LOCATION} -DPTRIE_BuildTest=OFF -DCMAKE_BUILD_TYPE=Release
76
    )
213.1.30 by Peter G. Jensen
commit removing old files, swithing to propper CMAKE
77
    ExternalProject_add(rapidxml-ext
78
        URL https://downloads.sourceforge.net/project/rapidxml/rapidxml/rapidxml%201.13/rapidxml-1.13.zip
79
        URL_HASH SHA512=6c10583e6631ccdb0217d0a5381172cb4c1046226de6ef1acf398d85e81d145228e14c3016aefcd7b70a1db8631505b048d8b4f5d4b0dbf1811d2482eefdd265
80
        BUILD_COMMAND ""
81
        CONFIGURE_COMMAND mkdir -p ${CMAKE_BINARY_DIR}/external/include
82
        INSTALL_COMMAND cd ../rapidxml-ext && ${CMAKE_COMMAND} -E copy rapidxml.hpp rapidxml_iterators.hpp rapidxml_print.hpp rapidxml_utils.hpp ${EXTERNAL_INSTALL_LOCATION}/include    
83
    )
84
213.3.1 by Kenneth Yrke Jørgensen
Added depend on glpk and switch for setting windows switch when cross compiling
85
    if (WIN32) #If windows 32 or 64 
213.1.148 by Kenneth Yrke Jørgensen
Updated argeument for cross compile glpk for windows
86
      set(GLPK_CFLAGS "-D __WOE__ -O3" )
213.1.122 by Peter G. Jensen
fixing compile flags for glpk
87
    else(WIN32)
213.1.148 by Kenneth Yrke Jørgensen
Updated argeument for cross compile glpk for windows
88
      set(GLPK_CFLAGS "-O3" )
213.3.1 by Kenneth Yrke Jørgensen
Added depend on glpk and switch for setting windows switch when cross compiling
89
    endif(WIN32)
213.1.61 by Peter G. Jensen
added glpk as external dependency
90
    ExternalProject_add(glpk-ext
91
        URL https://ftp.gnu.org/gnu/glpk/glpk-4.65.tar.gz
92
        URL_HASH SHA512=997e8e599ff1718a08c66b86eadd0e01f4644899f1e95920f8ae91d66b4d8361021766b346845f4dcbcfe667b41ab72ea3d377017a0ebf85d7ece091cfd81375
213.1.148 by Kenneth Yrke Jørgensen
Updated argeument for cross compile glpk for windows
93
	CONFIGURE_COMMAND CC=${CMAKE_C_COMPILER} CXX=${CMAKE_CXX_COMPILER} <SOURCE_DIR>/configure --enable-shared=no --prefix=${EXTERNAL_INSTALL_LOCATION} CFLAGS=${GLPK_CFLAGS}
213.1.122 by Peter G. Jensen
fixing compile flags for glpk
94
	BUILD_COMMAND make
213.1.61 by Peter G. Jensen
added glpk as external dependency
95
        INSTALL_COMMAND make install
213.1.118 by Peter G. Jensen
added patch to supress glpk warning
96
        PATCH_COMMAND patch -p1 < ${PROJECT_SOURCE_DIR}/glpk-warning.patch
213.1.61 by Peter G. Jensen
added glpk as external dependency
97
    )
98
99
    link_directories(${EXTERNAL_INSTALL_LOCATION}/lib)
100
    link_directories(${EXTERNAL_INSTALL_LOCATION}/lib64)
101
213.1.30 by Peter G. Jensen
commit removing old files, swithing to propper CMAKE
102
    # we can now include external libraries
103
    include_directories(${EXTERNAL_INSTALL_LOCATION}/include)
104
endif (VERIFYPN_GetDependencies)
105
include_directories(include)
106
107
add_subdirectory(${CMAKE_SOURCE_DIR}/src/)