summaryrefslogtreecommitdiffstats
path: root/ConfigureChecks.cmake
blob: c57f627ee6f4a1b7d45f0ab0bbf80ef30ce646c0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
###########################################
#                                         #
#  Improvements and feedback are welcome  #
#                                         #
#  This file is released under GPL >= 3   #
#                                         #
###########################################

# required stuff
find_package( TQt )
find_package( TDE )

tde_setup_architecture_flags( )

include(TestBigEndian)
test_big_endian(WORDS_BIGENDIAN)

tde_setup_largefiles( )


##### check for gcc visibility support

if( WITH_GCC_VISIBILITY )
  tde_setup_gcc_visibility( )
endif( WITH_GCC_VISIBILITY )


##### look for gpsim

if( NOT WITH_GPSIM )
    set( NO_GPSIM 1 )
 else()
    find_path( HAVE_GPSIM_INCLUDE "gpsim/cod.h" )
    find_library( HAVE_GPSIM_LIBRARY gpsim)

    if( (NOT HAVE_GPSIM_INCLUDE) OR (NOT HAVE_GPSIM_LIBRARY) )
        tde_message_fatal( "gpsim support have been requested but was not found on your system" )
     else()
        set( GPSIM_INCLUDE_DIRS ${HAVE_GPSIM_INCLUDE} )
        set( GPSIM_LIBRARIES gpsim;gpsimcli )

##### glib-1.2 or glib-2.0

        pkg_search_module( GLIB glib-2.0 glib )
        message( STATUS "glib version: ${GLIB_VERSION}" )

        if( NOT GLIB_FOUND )
            tde_message_fatal( "glib is required but was not found on your system" )
        endif()

        tde_save( CMAKE_REQUIRED_INCLUDES )
        set( CMAKE_REQUIRED_INCLUDES ${GLIB_INCLUDE_DIRS} ${GPSIM_INCLUDE_DIRS})

##### check for gpsim version

        if( EXISTS ${GPSIM_INCLUDE_DIRS}/gpsim/breakpoints.h )
          file( STRINGS ${GPSIM_INCLUDE_DIRS}/gpsim/breakpoints.h
                GPSIM_BROKEN_INCLUDE
                REGEX "^#include \"../config.h" )
          if( NOT "${GPSIM_BROKEN_INCLUDE}" STREQUAL "" )
            message( STATUS "Create fake config.h, due to broken gpsim includes" )
            list( APPEND CMAKE_REQUIRED_INCLUDES "${CMAKE_BINARY_DIR}/CMakeFiles" )
            list( APPEND GPSIM_INCLUDE_DIRS "${CMAKE_BINARY_DIR}/src" )
            if( NOT EXISTS "${CMAKE_BINARY_DIR}/config.h" )
              file( WRITE "${CMAKE_BINARY_DIR}/config.h"
                    "/* fake config.h - due to broken gpsim includes */" )
            endif()
          endif()
        endif()

        check_cxx_source_compiles( "
        #include <gpsim/interface.h>
        #include <gpsim/gpsim_interface.h>
        #include <gpsim/breakpoints.h>
        #include <gpsim/gpsim_time.h>
        void func()
        {
            (void)cycles;
            (void)initialize_gpsim_core();
            (void)load_symbol_file(0,0);
        }
        int main()
        {
            return 0;
        } "
        GPSIM_0_21_4
        )

        check_cxx_source_compiles( "
        #include <gpsim/interface.h>
        #include <gpsim/gpsim_interface.h>
        #include <gpsim/breakpoints.h>
        #include <gpsim/gpsim_time.h>
        #include <gpsim/symbol.h>
        #include <gpsim/program_files.h>
        void func()
        {
            (void)cycles;
            (void)initialize_gpsim_core();
        }
        int main()
        {
            return 0;
        } "
        GPSIM_0_21_11
        )
   
        check_cxx_source_compiles( "
        #include <gpsim/ValueCollections.h>
        int main()
        {
            return 0;
        } "
        GPSIM_0_21_12
        )

        check_cxx_source_compiles( "
        #include <gpsim/pic-processor.h>
        void func()
        {
            pic_processor *Processor;
            sizeof(Processor->Wreg);
        }
        int main()
        {
            return 0;
        } "
        GPSIM_0_27_0
        )
       tde_restore( CMAKE_REQUIRED_INCLUDES )
    endif((NOT HAVE_GPSIM_INCLUDE) OR (NOT HAVE_GPSIM_LIBRARY))
endif( NOT WITH_GPSIM )


##### mechanics

if( WITH_MECHANICS )
    set( MECHANICS 1 )
endif()