Redid static ctor/dtor handling to be compatible with init_array/fini_array as well...
[dyninst.git] / cmake / packages.cmake
1 if (UNIX)
2
3 include(ExternalProject)
4
5 find_package (LibElf)
6 if(NOT LIBELF_FOUND)
7 message(STATUS "No libelf found, attempting to build as external project")
8 ExternalProject_Add(LibElf
9         PREFIX ${CMAKE_SOURCE_DIR}/libelf
10         URL http://www.mr511.de/software/libelf-0.8.13.tar.gz
11         CONFIGURE_COMMAND <SOURCE_DIR>/configure --enable-shared --prefix=${CMAKE_SOURCE_DIR}/libelf
12         BUILD_COMMAND make
13         INSTALL_COMMAND make install
14 )
15 set(LIBELF_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/libelf/include)
16 set(LIBELF_LIBRARIES ${CMAKE_SOURCE_DIR}/libelf/lib/libelf.so)
17 set(SHOULD_INSTALL_LIBELF 1)
18 else()
19 set(SHOULD_INSTALL_LIBELF 0)
20 endif()
21
22 add_library(libelf_imp SHARED IMPORTED)
23 set_property(TARGET libelf_imp
24                     PROPERTY IMPORTED_LOCATION ${LIBELF_LIBRARIES}) 
25
26 find_package (LibDwarf)
27
28 if(NOT LIBDWARF_FOUND)
29 message(STATUS "No libdwarf found, attempting to build as external project")
30 ExternalProject_Add(LibDwarf
31         PREFIX ${CMAKE_SOURCE_DIR}/libdwarf
32         DEPENDS libelf_imp
33         URL http://reality.sgiweb.org/davea/libdwarf-20130126.tar.gz
34         CONFIGURE_COMMAND CFLAGS=-I${LIBELF_INCLUDE_DIR} LDFLAGS=-L${CMAKE_SOURCE_DIR}/libelf/lib <SOURCE_DIR>/libdwarf/configure --enable-shared
35         BUILD_COMMAND make
36         INSTALL_DIR ${CMAKE_SOURCE_DIR}/libdwarf
37         INSTALL_COMMAND mkdir -p <INSTALL_DIR>/include && mkdir -p <INSTALL_DIR>/lib && install <SOURCE_DIR>/libdwarf/libdwarf.h <INSTALL_DIR>/include && install <SOURCE_DIR>/libdwarf/dwarf.h <INSTALL_DIR>/include && install <BINARY_DIR>/libdwarf.so <INSTALL_DIR>/lib
38 )
39 add_dependencies(LibDwarf libelf_imp)
40 target_link_libraries(LibDwarf libelf_imp)
41 #ExternalProject_Get_Property(LibDwarf 
42 set(LIBDWARF_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/libdwarf/include)
43 set(LIBDWARF_LIBRARIES ${CMAKE_SOURCE_DIR}/libdwarf/lib/libdwarf.so)
44 endif()
45
46 add_library(libdwarf_imp SHARED IMPORTED)
47 set_property(TARGET libdwarf_imp 
48                     PROPERTY IMPORTED_LOCATION ${LIBDWARF_LIBRARIES})
49 find_package (LibIberty)
50
51 if(NOT IBERTY_FOUND)
52 ExternalProject_Add(LibIberty
53         PREFIX ${CMAKE_SOURCE_DIR}/binutils
54         URL http://ftp.gnu.org/gnu/binutils/binutils-2.23.tar.gz
55         CONFIGURE_COMMAND CFLAGS=-fPIC CPPFLAGS=-fPIC PICFLAG=-fPIC <SOURCE_DIR>/libiberty/configure --prefix=${CMAKE_SOURCE_DIR}/libiberty --enable-shared
56         BUILD_COMMAND make all
57         INSTALL_DIR ${CMAKE_SOURCE_DIR}/libiberty
58         INSTALL_COMMAND install <BINARY_DIR>/libiberty.a <INSTALL_DIR>
59 )
60 set(IBERTY_LIBRARY ${CMAKE_SOURCE_DIR}/libiberty/libiberty.a)
61 endif()
62
63 message(STATUS "Using libiberty ${IBERTY_LIBRARY}")
64 add_library(libiberty_imp STATIC IMPORTED)
65 set_property(TARGET libiberty_imp
66                     PROPERTY IMPORTED_LOCATION ${IBERTY_LIBRARY})
67
68 find_package (ThreadDB)
69 include_directories (
70                     ${LIBELF_INCLUDE_DIR}
71                     ${LIBDWARF_INCLUDE_DIR}
72 )
73 elseif(WIN32)
74 find_package (DIASDK REQUIRED)
75 include_directories(${DIASDK_INCLUDE_DIR})
76 endif()
77
78 if (PLATFORM MATCHES "bgq")
79 # Not a find per se, just a magic include line
80 set (PATH_BGQ "/bgsys/drivers/ppcfloor" CACHE STRING "Path to BG/Q include files")
81 if (NOT (PATH_BGQ STREQUAL ""))
82 include_directories (${PATH_BGQ})
83 endif()
84 endif()
85
86
87 # UPDATE this for newer versions of Boost if you're using
88 # an older CMake and it complains that it can't find Boost
89 set(Boost_ADDITIONAL_VERSIONS "1.47" "1.47.0" "1.48" "1.48.0" "1.49" "1.49.0"
90                               "1.50" "1.50.0" "1.51" "1.51.0" "1.52" "1.52.0"
91                               "1.53" "1.53.0" "1.54" "1.54.0")
92
93 set (PATH_BOOST "/usr" CACHE STRING "Path to boost")
94 if (NOT (PATH_BOOST STREQUAL ""))
95   set (CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} ${PATH_BOOST}/lib ${PATH_BOOST}/lib64)
96   set (CMAKE_INCLUDE_PATH ${CMAKE_INCLUDE_PATH} ${PATH_BOOST}/include)
97 endif()
98
99 find_package (Boost REQUIRED)
100
101 include_directories (
102                     ${Boost_INCLUDE_DIRS}
103 )