@@ -13,44 +13,43 @@ if(WIN32)
13
13
SET (CMAKE_EXE_LINKER_FLAGS "/LARGEADDRESSAWARE ${CMAKE_EXE_LINKER_FLAGS} " )
14
14
endif (WIN32 )
15
15
16
- set (CMAKE_MODULE_PATH "${LLVM_DIR} /cmake/modules ${CMAKE_MODULE_PATH} " )
16
+ set (CMAKE_MODULE_PATH "${LLVM_DIR} /cmake/modules" " ${CMAKE_SOURCE_DIR} /cmake" " ${CMAKE_ROOT} /Modules " )
17
17
18
18
# Configure with the build LLVM
19
19
find_package (LLVM 3.8 REQUIRED CONFIG )
20
20
add_definitions (${LLVM_DEFINITIONS} )
21
21
22
- set (CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR} /cmake" ${CMAKE_MODULE_PATH} )
23
22
include (LLVMUtils )
24
23
include (GetGitRevisionDescription )
25
24
26
25
# we need C++11
27
26
if (NOT WIN32 )
28
27
# WIN32 defaults to CXX11 by default, and setting it explicitly here
29
28
# confuses clang-cl, which will bail out with "unknown flag -std=g++11"
29
+
30
+ #FindPackage for protobuf is terrible for win32
31
+ # it assumes MSVC built protobuf from a visual studio project
32
+ #... we build with custom cmake, so it will never be found
33
+ #... but it should work for other OSes where we install from a package
34
+
30
35
set (CMAKE_CXX_STANDARD 11 )
31
- endif ()
32
36
33
- # Get protobufs.
34
- if ( WIN32 )
35
- # Change the slashes to Unix style or risk the wrath of invalid escape
36
- # sequences!
37
- string ( REGEX REPLACE " \\\\ " "/" CMAKE_SOURCE_DIR ${CMAKE_SOURCE_DIR} )
37
+ if ( APPLE )
38
+ set ( PROTOBUF_ROOT " ${CMAKE_SOURCE_DIR} /third_party/protobuf" )
39
+ set ( Protobuf_LIBRARIES " ${PROTOBUF_ROOT} /build/lib" )
40
+ set ( Protobuf_INCLUDE_DIR " ${PROTOBUF_ROOT} /src" )
41
+ endif ( )
38
42
39
- set (PROTOBUF_ROOT "${CMAKE_SOURCE_DIR} /third_party/protobuf" )
40
- set (Protobuf_LIBRARIES "${PROTOBUF_ROOT} /build/libprotobuf/Release" )
41
- set (Protobuf_INCLUDE_DIR "${PROTOBUF_ROOT} /src" )
42
-
43
- include_directories (${Protobuf_INCLUDE_DIR} )
44
- link_directories (${Protobuf_LIBRARIES} )
45
- elseif (APPLE )
46
- set (PROTOBUF_ROOT "${CMAKE_SOURCE_DIR} /third_party/protobuf" )
47
- set (Protobuf_LIBRARIES "${PROTOBUF_ROOT} /build/lib" )
48
- set (Protobuf_INCLUDE_DIR "${PROTOBUF_ROOT} /src" )
49
-
50
- include_directories (${Protobuf_INCLUDE_DIR} )
51
- link_directories (${Protobuf_LIBRARIES} )
52
- endif (WIN32 )
53
- find_package (Protobuf REQUIRED )
43
+ find_package (Protobuf REQUIRED )
44
+ else ()
45
+ string (REGEX REPLACE "\\\\ " "/" CMAKE_SOURCE_DIR ${CMAKE_SOURCE_DIR} )
46
+ # on win32, manuallys set protobuf goodness
47
+ set (PROTOBUF_INCLUDE_DIRS "${CMAKE_SOURCE_DIR} /include" )
48
+ set (PROTOBUF_LIBRARIES "${CMAKE_SOURCE_DIR} /lib/protobuf.lib" )
49
+ set (PROTOBUF_PROTOC_EXECUTABLE "${CMAKE_SOURCE_DIR} /bin/protoc.exe" )
50
+ endif ()
51
+
52
+ include_directories (${PROTOBUF_INCLUDE_DIRS} )
54
53
55
54
include_directories (${CMAKE_SOURCE_DIR} )
56
55
include_directories (${CMAKE_SOURCE_DIR} /third_party )
@@ -168,9 +167,6 @@ include_directories("${CMAKE_BINARY_DIR}")
168
167
# this will make sure that the protobuf files are generated each time
169
168
# the CFG.h header file is modified
170
169
#
171
- # todo: use find protobuf CMake module to generate the files; this is
172
- # not easy on windows right now, since protoc is built on the fly.
173
- #
174
170
175
171
set (PROTOBUF_CONFIGURATION "${CMAKE_SOURCE_DIR} /mcsema/CFG/CFG.proto" )
176
172
@@ -180,16 +176,10 @@ set(PROTOBUF_OUTPUT_FILE_LIST
180
176
"${MCSEMA_GEN_DIR} /CFG_pb2.py"
181
177
)
182
178
183
- if (WIN32 )
184
- set (PROTOC_EXECUTABLE_PATH "${CMAKE_SOURCE_DIR} /third_party/protobuf/build/protoc/Release/protoc.exe" )
185
- else ()
186
- set (PROTOC_EXECUTABLE_PATH "protoc" )
187
- endif ()
188
-
189
179
add_custom_command (
190
180
OUTPUT ${PROTOBUF_OUTPUT_FILE_LIST}
191
181
192
- COMMAND "${PROTOC_EXECUTABLE_PATH } " --cpp_out "${MCSEMA_GEN_DIR} " --python_out "${MCSEMA_GEN_DIR} " --proto_path "${CMAKE_SOURCE_DIR} /mcsema/CFG" "${PROTOBUF_CONFIGURATION} "
182
+ COMMAND "${PROTOBUF_PROTOC_EXECUTABLE } " --cpp_out "${MCSEMA_GEN_DIR} " --python_out "${MCSEMA_GEN_DIR} " --proto_path "${CMAKE_SOURCE_DIR} /mcsema/CFG" "${PROTOBUF_CONFIGURATION} "
193
183
194
184
DEPENDS "${CMAKE_SOURCE_DIR} /mcsema/CFG/CFG.h"
195
185
MAIN_DEPENDENCY "${PROTOBUF_CONFIGURATION} "
@@ -236,7 +226,7 @@ add_executable(mcsema-lift
236
226
${CMAKE_SOURCE_DIR} /mcsema/Arch/X86/Semantics/SUB.cpp )
237
227
238
228
target_link_libraries (mcsema-lift
239
- protobuf
229
+ ${PROTOBUF_LIBRARIES}
240
230
LLVMBitReader
241
231
LLVMBitWriter
242
232
LLVMMCDisassembler
0 commit comments