Skip to content

Commit 2c6518e

Browse files
committed
Making the codebase compatible with macOS.
1 parent 7adf083 commit 2c6518e

File tree

28 files changed

+222
-27
lines changed

28 files changed

+222
-27
lines changed

CMakeLists.txt

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,13 @@ include(Functions.cmake)
1010
# Do some sanity check on the testing setup and enable testing if applicable.
1111
include(Testing.cmake)
1212

13-
find_package(Boost REQUIRED COMPONENTS filesystem log program_options regex system thread)
14-
find_package(Java REQUIRED)
15-
find_package(Odb REQUIRED)
16-
find_package(Threads REQUIRED)
17-
find_package(Thrift REQUIRED)
13+
find_package(Boost REQUIRED COMPONENTS filesystem log program_options regex system thread)
14+
find_package(Java REQUIRED)
15+
find_package(Odb REQUIRED)
16+
find_package(Threads REQUIRED)
17+
find_package(Thrift REQUIRED)
18+
find_package(Graphviz REQUIRED)
19+
find_package(LibMagic REQUIRED)
1820
find_package(GTest)
1921

2022
include(UseJava)

FindGraphviz.cmake

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
# - Try to find Graphviz
2+
# Once done this will define
3+
#
4+
# GRAPHVIZ_FOUND - system has Graphviz
5+
# GRAPHVIZ_INCLUDE_DIRS - Graphviz include directories
6+
# GRAPHVIZ_CDT_LIBRARY - Graphviz CDT library
7+
# GRAPHVIZ_GVC_LIBRARY - Graphviz GVC library
8+
# GRAPHVIZ_CGRAPH_LIBRARY - Graphviz CGRAPH library
9+
# GRAPHVIZ_PATHPLAN_LIBRARY - Graphviz PATHPLAN library
10+
# GRAPHVIZ_VERSION - Graphviz version
11+
#
12+
# This module reads hints about search locations from the following cmake variables:
13+
# GRAPHVIZ_ROOT - Graphviz installation prefix
14+
# (containing bin/, include/, etc.)
15+
16+
# Copyright (c) 2009, Adrien Bustany, <[email protected]>
17+
# Copyright (c) 2013-2014 Kevin Funk <[email protected]>
18+
19+
# Version computation and some cleanups by Allen Winter <[email protected]>
20+
# Copyright (c) 2012-2014 Klarälvdalens Datakonsult AB, a KDAB Group company <[email protected]>
21+
22+
# Simplified script by Dogan Can <[email protected]>
23+
# Copyright (c) 2014 University of Southern California
24+
25+
# Redistribution and use is allowed according to the terms of the GPLv3+ license.
26+
# Source: https://github.com/usc-sail/barista/blob/master/cmake/FindGraphviz.cmake
27+
28+
if(GRAPHVIZ_ROOT)
29+
set(_GRAPHVIZ_INCLUDE_DIR ${GRAPHVIZ_ROOT}/include)
30+
set(_GRAPHVIZ_LIBRARY_DIR ${GRAPHVIZ_ROOT}/lib)
31+
endif()
32+
33+
find_path(GRAPHVIZ_INCLUDE_DIR NAMES graphviz/cgraph.h
34+
HINTS ${_GRAPHVIZ_INCLUDE_DIR})
35+
find_library(GRAPHVIZ_CDT_LIBRARY NAMES cdt
36+
HINTS ${_GRAPHVIZ_LIBRARY_DIR})
37+
find_library(GRAPHVIZ_GVC_LIBRARY NAMES gvc
38+
HINTS ${_GRAPHVIZ_LIBRARY_DIR})
39+
find_library(GRAPHVIZ_CGRAPH_LIBRARY NAMES cgraph
40+
HINTS ${_GRAPHVIZ_LIBRARY_DIR})
41+
find_library(GRAPHVIZ_PATHPLAN_LIBRARY NAMES pathplan
42+
HINTS ${_GRAPHVIZ_LIBRARY_DIR})
43+
44+
if(GRAPHVIZ_INCLUDE_DIR AND GRAPHVIZ_CDT_LIBRARY AND GRAPHVIZ_GVC_LIBRARY
45+
AND GRAPHVIZ_CGRAPH_LIBRARY AND GRAPHVIZ_PATHPLAN_LIBRARY)
46+
set(GRAPHVIZ_FOUND TRUE)
47+
else()
48+
set(GRAPHVIZ_FOUND FALSE)
49+
endif()
50+
51+
# Ok, now compute the version
52+
if(GRAPHVIZ_FOUND)
53+
set(FIND_GRAPHVIZ_VERSION_SOURCE
54+
"#include <graphviz/graphviz_version.h>\n#include <stdio.h>\n int main()\n {\n printf(\"%s\",PACKAGE_VERSION);return 1;\n }\n")
55+
set(FIND_GRAPHVIZ_VERSION_SOURCE_FILE ${CMAKE_BINARY_DIR}/CMakeTmp/FindGRAPHVIZ.cxx)
56+
file(WRITE "${FIND_GRAPHVIZ_VERSION_SOURCE_FILE}" "${FIND_GRAPHVIZ_VERSION_SOURCE}")
57+
58+
set(FIND_GRAPHVIZ_VERSION_ADD_INCLUDES
59+
"-DINCLUDE_DIRECTORIES:STRING=${GRAPHVIZ_INCLUDE_DIR}")
60+
61+
try_run(RUN_RESULT COMPILE_RESULT
62+
${CMAKE_BINARY_DIR}
63+
${FIND_GRAPHVIZ_VERSION_SOURCE_FILE}
64+
CMAKE_FLAGS "${FIND_GRAPHVIZ_VERSION_ADD_INCLUDES}"
65+
RUN_OUTPUT_VARIABLE GRAPHVIZ_VERSION)
66+
67+
if(COMPILE_RESULT AND RUN_RESULT EQUAL 1)
68+
message(STATUS "Graphviz version: ${GRAPHVIZ_VERSION}")
69+
else()
70+
message(FATAL_ERROR "Unable to compile or run the graphviz version detection program.")
71+
endif()
72+
73+
set(GRAPHVIZ_INCLUDE_DIRS ${GRAPHVIZ_INCLUDE_DIR} ${GRAPHVIZ_INCLUDE_DIR}/graphviz)
74+
75+
if(NOT Graphviz_FIND_QUIETLY)
76+
message(STATUS "Graphviz include: ${GRAPHVIZ_INCLUDE_DIRS}")
77+
message(STATUS "Graphviz libraries: ${GRAPHVIZ_CDT_LIBRARY} ${GRAPHVIZ_GVC_LIBRARY} ${GRAPHVIZ_CGRAPH_LIBRARY} ${GRAPHVIZ_PATHPLAN_LIBRARY}")
78+
endif()
79+
endif()
80+
81+
if(Graphviz_FIND_REQUIRED AND NOT GRAPHVIZ_FOUND)
82+
message(FATAL_ERROR "Could not find GraphViz.")
83+
endif()

Functions.cmake

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ function(generate_odb_files _src)
2525
-I ${CMAKE_SOURCE_DIR}/model/include
2626
-I ${CMAKE_SOURCE_DIR}/util/include
2727
-I ${ODB_INCLUDE_DIRS}
28+
-I ${Boost_INCLUDE_DIRS}
2829
${CMAKE_CURRENT_SOURCE_DIR}/${_file}
2930
COMMAND
3031
mv ${CMAKE_CURRENT_BINARY_DIR}/include/model/${_cxx}
@@ -46,6 +47,7 @@ function(add_odb_library _name)
4647
target_link_libraries(${_name} ${ODB_LIBRARIES})
4748
target_include_directories(${_name} PUBLIC
4849
${ODB_INCLUDE_DIRS}
50+
${Boost_INCLUDE_DIRS}
4951
${CMAKE_SOURCE_DIR}/util/include
5052
${CMAKE_SOURCE_DIR}/model/include
5153
${CMAKE_CURRENT_SOURCE_DIR}/include

doc/deps.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ cd thrift-0.13.0
192192
--without-php --without-php_extension --without-dart \
193193
--without-haskell --without-go --without-rs --without-haxe \
194194
--without-dotnetcore --without-d --without-qt4 --without-qt5 \
195-
--without-java
195+
--without-java --without-swift
196196

197197
make install -j $(nproc)
198198
```

logger/src/ldlogger-util.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22
#define CC_LOGGER_UTIL_H
33

44
#include <limits.h>
5+
#ifdef __linux__
56
#include <linux/limits.h>
7+
#endif
68
#include <string.h>
79

810
/**

model/include/model/buildaction.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#ifndef CC_MODEL_BUILDACTION_H
22
#define CC_MODEL_BUILDACTION_H
33

4+
#include <cstdint>
45
#include <string>
56
#include <memory>
67
#include <vector>

parser/CMakeLists.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ include_directories(
44
${PROJECT_SOURCE_DIR}/model/include)
55

66
include_directories(SYSTEM
7-
${ODB_INCLUDE_DIRS})
7+
${ODB_INCLUDE_DIRS}
8+
${LIBMAGIC_INCLUDES})
89

910
add_executable(CodeCompass_parser
1011
src/pluginhandler.cpp
@@ -21,7 +22,7 @@ target_link_libraries(CodeCompass_parser
2122
${Boost_LIBRARIES}
2223
${ODB_LIBRARIES}
2324
${CMAKE_DL_LIBS}
24-
magic
25+
${LIBMAGIC_LIBRARIES}
2526
pthread)
2627

2728
install(TARGETS CodeCompass_parser

plugins/cpp/model/include/model/cppinheritance.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
#define CC_MODEL_CPPINHERITANCE_H
33

44
#include <memory>
5+
#include <cstdint>
6+
57
#include "common.h"
68

79
namespace cc

plugins/cpp/parser/CMakeLists.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,13 @@ target_link_libraries(cppparser
6565

6666
target_compile_options(cppparser PUBLIC -Wno-unknown-pragmas)
6767

68+
if(APPLE)
69+
# Use Linux-like linking behaviour, dynamic libraries may contain references without implementation.
70+
# cppparser references headers from the parser without implementation
71+
set_target_properties(cppparser PROPERTIES LINK_FLAGS
72+
"-undefined dynamic_lookup")
73+
endif(APPLE)
74+
6875
install(TARGETS cppparser DESTINATION ${INSTALL_PARSER_DIR})
6976

7077
# Install Clang additional files

plugins/cpp/service/CMakeLists.txt

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,14 @@ target_link_libraries(cppservice
2626
mongoose
2727
projectservice
2828
languagethrift
29-
gvc
29+
${GRAPHVIZ_GVC_LIBRARY}
3030
${THRIFT_LIBTHRIFT_LIBRARIES})
3131

32+
if(APPLE)
33+
# Use Linux-like linking behaviour, dynamic libraries may contain references without implementation.
34+
# cppservice references headers from the webserver without implementation
35+
set_target_properties(cppservice PROPERTIES LINK_FLAGS
36+
"-undefined dynamic_lookup")
37+
endif(APPLE)
38+
3239
install(TARGETS cppservice DESTINATION ${INSTALL_SERVICE_DIR})

0 commit comments

Comments
 (0)