123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186 |
- cmake_minimum_required(VERSION 3.5)
- ################### Variables. ####################
- # Change if you want modify path or other values. #
- ###################################################
- set(PROJECT_NAME BeefFuzz)
- # Output Variables
- set(OUTPUT_DEBUG Debug/bin)
- set(OUTPUT_RELEASE Release/bin)
- ############## CMake Project ################
- # The main options of project #
- #############################################
- project(${PROJECT_NAME} CXX C)
- set (CMAKE_CXX_STANDARD 14)
- add_definitions(-D_GLIBCXX_USE_CXX11_ABI=1)
- #set(CMAKE_POSITION_INDEPENDENT_CODE ON)
- # Define Release by default.
- if(NOT CMAKE_BUILD_TYPE)
- set(CMAKE_BUILD_TYPE "Debug")
- message(STATUS "Build type not specified: Use Debug by default.")
- endif(NOT CMAKE_BUILD_TYPE)
- # Definition of Macros
- add_definitions(
- -DIDEHELPER_EXPORTS
- -DBFSYSLIB_DYNAMIC
- -DUNICODE
- -D_UNICODE
- -DBF_NO_FBX
- -DFT2_BUILD_LIBRARY
- -DBFSYSLIB_DYNAMIC
- )
- if (${APPLE})
- include_directories(
- .
- ../
- ../BeefySysLib/
- ../BeefySysLib/third_party
- ../BeefySysLib/third_party/freetype/include
- ../IDEHelper
- ../BeefySysLib/platform/osx
- )
- else()
- include_directories(
- .
- ../
- ../BeefySysLib/
- ../BeefySysLib/third_party
- ../BeefySysLib/third_party/freetype/include
- ../IDEHelper
- ../BeefySysLib/platform/linux
- )
- endif()
- ############## Artefacts Output #################
- # Defines outputs , depending Debug or Release. #
- #################################################
- if(CMAKE_BUILD_TYPE STREQUAL "Debug")
- add_definitions(
- -D_DEBUG
- )
- set(EXECUTABLE_OUTPUT_PATH "${CMAKE_BINARY_DIR}/${OUTPUT_DEBUG}")
- else()
- set(EXECUTABLE_OUTPUT_PATH "${CMAKE_BINARY_DIR}/${OUTPUT_RELEASE}")
- endif()
- ################### Dependencies ##################
- # Add Dependencies to project. #
- ###################################################
- option(BUILD_DEPENDS
- "Build other CMake project."
- ON
- )
- # Dependencies : disable BUILD_DEPENDS to link with lib already build.
- if(BUILD_DEPENDS)
- else()
- endif()
- ################# Flags ################
- # Defines Flags for Windows and Linux. #
- ########################################
- if(MSVC)
- set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /W3 /MD /MDd /Od /EHsc")
- set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /W3 /GL /Od /Oi /Gy /EHsc")
- else()
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17 -Wno-multichar -Wno-invalid-offsetof -fno-omit-frame-pointer -fsanitize=fuzzer")
- if (BF_ENABLE_ASAN)
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address")
- endif()
- endif()
- ################ Files ################
- # -- Add files to project. -- #
- #######################################
- file(GLOB SRC_FILES
- BeefFuzz.cpp
- FuzzApp.cpp
- )
- # Add executable to build.
- add_executable(${PROJECT_NAME}
- ${SRC_FILES}
- )
- find_package(LLVM 13 CONFIG COMPONENTS)
- if (LLVM_FOUND)
- message(STATUS "Found LLVM ${LLVM_PACKAGE_VERSION}")
- message(STATUS "Using LLVMConfig.cmake in: ${LLVM_DIR}")
- include_directories(${LLVM_INCLUDE_DIRS})
- add_definitions(${LLVM_DEFINITIONS})
- set(TARGET_LIBS_OS "-lLLVM-13")
- else()
- include_directories(
- ../extern/llvm-project_13_0_1/llvm/include
- ../extern/llvm-project_13_0_1/llvm/lib/Target
- )
- if(CMAKE_BUILD_TYPE STREQUAL "Debug")
- include_directories(
- ../extern/llvm_linux_13_0_1/include
- ../extern/llvm_linux_13_0_1/lib/Target/X86
- )
- set(LLVM_LIB "${CMAKE_CURRENT_SOURCE_DIR}/../extern/llvm_linux_13_0_1/lib")
- else()
- include_directories(
- ../extern/llvm_linux_rel_13_0_1/include
- ../extern/llvm_linux_rel_13_0_1/lib/Target/X86
- )
- set(LLVM_LIB "${CMAKE_CURRENT_SOURCE_DIR}/../extern/llvm_linux_rel_13_0_1/lib")
- endif()
- execute_process(
- COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/../extern/llvm_linux_13_0_1/bin/llvm-config --system-libs --link-static
- OUTPUT_VARIABLE LLVM_SYSTEM_LIBS
- OUTPUT_STRIP_TRAILING_WHITESPACE
- RESULT_VARIABLE EXEC_RESULT
- )
- if (EXEC_RESULT AND NOT EXEC_RESULT EQUAL 0)
- if (EXEC_RESULT MATCHES "^[0-9]+$")
- message(FATAL_ERROR "llvm-config exited with code ${EXEC_RESULT}.")
- else()
- message(FATAL_ERROR "llvm-config couldn't be executed: ${EXEC_RESULT}")
- endif()
- endif()
-
- message(STATUS "Found LLVM 13.0.1 (local build)")
- endif()
- if (${APPLE})
- set(TARGET_LIBS_OS "")
- else()
- #set(TARGET_LIBS_OS "curses")
- #set(TARGET_LIBS_OS "-Xlinker --no-demangle -v")
- set(TARGET_LIBS_OS "${LLVM_SYSTEM_LIBS}")
- endif()
- # Link with other dependencies.
- if(MSVC)
- target_link_libraries(${PROJECT_NAME} BeefySysLib IDEHelper kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib)
- else()
- target_link_libraries(${PROJECT_NAME} BeefySysLib
- IDEHelper
- ${TARGET_LIBS_OS}
- )
- endif()
|