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

+7-5
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

+83
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

+2
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

+1-1
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

+2
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

+1
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

+3-2
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

+2
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

+7
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

+8-1
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})

plugins/cpp_reparse/service/CMakeLists.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ include_directories(
1313
${cpp_PLUGIN_DIR}/parser/include)
1414

1515
include_directories(SYSTEM
16+
${Boost_INCLUDE_DIRS}
1617
${THRIFT_LIBTHRIFT_INCLUDE_DIRS}
1718
${LLVM_INCLUDE_DIRS}
1819
${CLANG_INCLUDE_DIRS})
@@ -72,8 +73,7 @@ target_link_libraries(cppreparseservice
7273
clangFrontend
7374
clangBasic
7475
clangAST
75-
clang
76-
)
76+
clang)
7777

7878
install(TARGETS cppreparseservice DESTINATION ${INSTALL_SERVICE_DIR})
7979
install_js_thrift()

plugins/dummy/parser/CMakeLists.txt

+6
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,15 @@ include_directories(
44
${PROJECT_SOURCE_DIR}/util/include
55
${PROJECT_SOURCE_DIR}/parser/include)
66

7+
include_directories(SYSTEM
8+
${Boost_INCLUDE_DIRS})
9+
710
add_library(dummyparser SHARED
811
src/dummyparser.cpp)
912

1013
target_compile_options(dummyparser PUBLIC -Wno-unknown-pragmas)
1114

15+
target_link_libraries(dummyparser
16+
${Boost_LIBRARIES})
17+
1218
install(TARGETS dummyparser DESTINATION ${INSTALL_PARSER_DIR})

plugins/dummy/service/CMakeLists.txt

+8
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ include_directories(
55
${PROJECT_SOURCE_DIR}/webserver/include)
66

77
include_directories(SYSTEM
8+
${Boost_INCLUDE_DIRS}
89
${THRIFT_LIBTHRIFT_INCLUDE_DIRS})
910

1011
add_custom_command(
@@ -44,4 +45,11 @@ target_link_libraries(dummyservice
4445
${ODB_LIBRARIES}
4546
dummythrift)
4647

48+
if(APPLE)
49+
# Use Linux-like linking behaviour, dynamic libraries may contain references without implementation.
50+
# dummyservice references headers from the webserver without implementation
51+
set_target_properties(dummyservice PROPERTIES LINK_FLAGS
52+
"-undefined dynamic_lookup")
53+
endif(APPLE)
54+
4755
install(TARGETS dummyservice DESTINATION ${INSTALL_SERVICE_DIR})

plugins/git/parser/CMakeLists.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ target_compile_options(gitparser PUBLIC -Wno-unknown-pragmas)
1010

1111
target_link_libraries(gitparser
1212
util
13-
git2
14-
ssl)
13+
${LIBGIT2_LIBRARIES}
14+
${OPENSSL_SSL_LIBRARY})
1515

1616
install(TARGETS gitparser DESTINATION ${INSTALL_PARSER_DIR})

plugins/git/service/CMakeLists.txt

+9-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ include_directories(
99
${PLUGIN_DIR}/model/include)
1010

1111
include_directories(SYSTEM
12+
${Boost_INCLUDE_DIRS}
1213
${THRIFT_LIBTHRIFT_INCLUDE_DIRS})
1314

1415
add_custom_command(
@@ -49,7 +50,14 @@ target_link_libraries(gitservice
4950
${THRIFT_LIBTHRIFT_LIBRARIES}
5051
${ODB_LIBRARIES}
5152
gitthrift
52-
git2)
53+
${LIBGIT2_LIBRARIES})
54+
55+
if(APPLE)
56+
# Use Linux-like linking behaviour, dynamic libraries may contain references without implementation.
57+
# gitservice references headers from the webserver without implementation
58+
set_target_properties(gitservice PROPERTIES LINK_FLAGS
59+
"-undefined dynamic_lookup")
60+
endif(APPLE)
5361

5462
install(TARGETS gitservice DESTINATION ${INSTALL_SERVICE_DIR})
5563
install_js_thrift()

plugins/metrics/parser/CMakeLists.txt

+7
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,13 @@ target_link_libraries(metricsparser
1313
util
1414
${Boost_LIBRARIES})
1515

16+
if(APPLE)
17+
# Use Linux-like linking behaviour, dynamic libraries may contain references without implementation.
18+
# metricsparser references headers from the parser without implementation
19+
set_target_properties(metricsparser PROPERTIES LINK_FLAGS
20+
"-undefined dynamic_lookup")
21+
endif(APPLE)
22+
1623
install(TARGETS metricsparser
1724
LIBRARY DESTINATION ${INSTALL_LIB_DIR}
1825
DESTINATION ${INSTALL_PARSER_DIR})

plugins/metrics/service/CMakeLists.txt

+8
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ include_directories(
88
${PROJECT_SOURCE_DIR}/webserver/include)
99

1010
include_directories(SYSTEM
11+
${Boost_INCLUDE_DIRS}
1112
${THRIFT_LIBTHRIFT_INCLUDE_DIRS})
1213

1314
add_custom_command(
@@ -52,5 +53,12 @@ target_link_libraries(metricsservice
5253
commonthrift
5354
metricsthrift)
5455

56+
if(APPLE)
57+
# Use Linux-like linking behaviour, dynamic libraries may contain references without implementation.
58+
# metricsservice references headers from the webserver without implementation
59+
set_target_properties(metricsservice PROPERTIES LINK_FLAGS
60+
"-undefined dynamic_lookup")
61+
endif(APPLE)
62+
5563
install(TARGETS metricsservice DESTINATION ${INSTALL_SERVICE_DIR})
5664
install_js_thrift()

plugins/search/indexer/CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ include_directories(
44
${PROJECT_SOURCE_DIR}/util/include)
55

66
include_directories(SYSTEM
7+
${Boost_INCLUDE_DIRS}
78
${THRIFT_LIBTHRIFT_INCLUDE_DIRS})
89

910
add_custom_command(

plugins/search/parser/CMakeLists.txt

+10-2
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,22 @@ include_directories(
88
${PLUGIN_DIR}/indexer/include)
99

1010
include_directories(SYSTEM
11-
${THRIFT_LIBTHRIFT_INCLUDE_DIRS})
11+
${THRIFT_LIBTHRIFT_INCLUDE_DIRS}
12+
${LIBMAGIC_INCLUDES})
1213

1314
add_library(searchparser SHARED src/searchparser.cpp)
1415
target_link_libraries(searchparser
1516
util
16-
magic
17+
${LIBMAGIC_LIBRARIES}
1718
indexerservice)
1819

1920
target_compile_options(searchparser PUBLIC -Wno-unknown-pragmas)
2021

22+
if(APPLE)
23+
# Use Linux-like linking behaviour, dynamic libraries may contain references without implementation.
24+
# searchparser references headers from the parser without implementation
25+
set_target_properties(searchparser PROPERTIES LINK_FLAGS
26+
"-undefined dynamic_lookup")
27+
endif(APPLE)
28+
2129
install(TARGETS searchparser DESTINATION ${INSTALL_PARSER_DIR})

plugins/search/service/CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ include_directories(
99
${PLUGIN_DIR}/model/include)
1010

1111
include_directories(SYSTEM
12+
${Boost_INCLUDE_DIRS}
1213
${THRIFT_LIBTHRIFT_INCLUDE_DIRS})
1314

1415
# Generate thrift files

service/authentication/CMakeLists.txt

+8
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ include_directories(
55
${PROJECT_SOURCE_DIR}/webserver/include)
66

77
include_directories(SYSTEM
8+
${Boost_INCLUDE_DIRS}
89
${THRIFT_LIBTHRIFT_INCLUDE_DIRS})
910

1011
add_custom_command(
@@ -44,5 +45,12 @@ target_link_libraries(authenticationservice
4445
${THRIFT_LIBTHRIFT_LIBRARIES}
4546
authenticationthrift)
4647

48+
if(APPLE)
49+
# Use Linux-like linking behaviour, dynamic libraries may contain references without implementation.
50+
# authenticationservice references headers from the webserver without implementation
51+
set_target_properties(authenticationservice PROPERTIES LINK_FLAGS
52+
"-undefined dynamic_lookup")
53+
endif(APPLE)
54+
4755
install(TARGETS authenticationservice DESTINATION ${INSTALL_SERVICE_DIR})
4856
install_js_thrift()

service/language/CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ include_directories(
22
${PROJECT_BINARY_DIR}/service/project/gen-cpp)
33

44
include_directories(SYSTEM
5+
${Boost_INCLUDE_DIRS}
56
${THRIFT_LIBTHRIFT_INCLUDE_DIRS})
67

78
add_custom_command(

0 commit comments

Comments
 (0)