2019-08-23 11:56:54 -07:00
|
|
|
cmake_minimum_required(VERSION 3.0.0 FATAL_ERROR)
|
|
|
|
|
|
|
|
################### Variables. ####################
|
|
|
|
# Change if you want modify path or other values. #
|
|
|
|
###################################################
|
|
|
|
|
|
|
|
set(PROJECT_NAME IDEHelper)
|
|
|
|
# Output Variables
|
|
|
|
set(OUTPUT_DEBUG Debug/bin)
|
|
|
|
set(CMAKE_DEBUG_POSTFIX "_d")
|
|
|
|
set(OUTPUT_RELEASE Release/bin)
|
|
|
|
|
|
|
|
############## CMake Project ################
|
|
|
|
# The main options of project #
|
|
|
|
#############################################
|
|
|
|
|
|
|
|
project(${PROJECT_NAME} CXX C)
|
|
|
|
|
|
|
|
# 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(
|
2022-07-22 18:45:21 +02:00
|
|
|
-DIDEHELPER_EXPORTS
|
|
|
|
-DBFSYSLIB_DYNAMIC
|
2019-08-23 11:56:54 -07:00
|
|
|
-DUNICODE
|
|
|
|
-D_UNICODE
|
|
|
|
-DBF_NO_FBX
|
|
|
|
-DFT2_BUILD_LIBRARY
|
|
|
|
-DBFSYSLIB_DYNAMIC
|
|
|
|
)
|
|
|
|
|
2024-05-07 18:09:01 -04:00
|
|
|
set (CMAKE_CXX_STANDARD 17)
|
2020-05-21 06:58:26 -07:00
|
|
|
#add_definitions(-D_GLIBCXX_USE_CXX11_ABI=1)
|
|
|
|
|
2020-05-21 12:55:58 -07:00
|
|
|
INCLUDE(CheckIncludeFiles)
|
|
|
|
CHECK_INCLUDE_FILES(backtrace.h HAVE_BACKTRACE_HEADERS)
|
|
|
|
if (HAVE_BACKTRACE_HEADERS)
|
2022-07-22 18:45:21 +02:00
|
|
|
add_definitions(-DBFP_HAS_BACKTRACE)
|
2020-05-21 12:55:58 -07:00
|
|
|
endif ()
|
|
|
|
|
2019-10-14 14:08:29 -07:00
|
|
|
if (${APPLE})
|
|
|
|
include_directories(
|
|
|
|
.
|
|
|
|
../
|
2022-07-22 18:45:21 +02:00
|
|
|
../BeefySysLib/
|
2019-10-14 14:08:29 -07:00
|
|
|
../BeefySysLib/third_party
|
2022-07-22 18:45:21 +02:00
|
|
|
../BeefySysLib/third_party/freetype/include
|
2019-10-14 14:08:29 -07:00
|
|
|
|
|
|
|
../BeefySysLib/platform/osx
|
|
|
|
)
|
|
|
|
else()
|
|
|
|
include_directories(
|
|
|
|
.
|
|
|
|
../
|
2022-07-22 18:45:21 +02:00
|
|
|
../BeefySysLib/
|
2019-10-14 14:08:29 -07:00
|
|
|
../BeefySysLib/third_party
|
2022-07-22 18:45:21 +02:00
|
|
|
../BeefySysLib/third_party/freetype/include
|
2019-10-14 14:08:29 -07:00
|
|
|
|
2022-07-22 18:45:21 +02:00
|
|
|
../BeefySysLib/platform/linux
|
2019-10-14 14:08:29 -07:00
|
|
|
)
|
|
|
|
endif()
|
2019-08-23 11:56:54 -07:00
|
|
|
|
|
|
|
############## Artefacts Output #################
|
|
|
|
# Defines outputs , depending Debug or Release. #
|
|
|
|
#################################################
|
|
|
|
|
|
|
|
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
|
|
|
|
add_definitions(
|
|
|
|
-D_DEBUG
|
|
|
|
)
|
|
|
|
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${OUTPUT_DEBUG}")
|
|
|
|
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${OUTPUT_DEBUG}")
|
|
|
|
set(CMAKE_EXECUTABLE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${OUTPUT_DEBUG}")
|
|
|
|
else()
|
|
|
|
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${OUTPUT_RELEASE}")
|
|
|
|
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${OUTPUT_RELEASE}")
|
|
|
|
set(CMAKE_EXECUTABLE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${OUTPUT_RELEASE}")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
################### Dependencies ##################
|
|
|
|
# Add Dependencies to project. #
|
|
|
|
###################################################
|
|
|
|
|
2022-07-22 18:45:21 +02:00
|
|
|
option(BUILD_DEPENDS
|
|
|
|
"Build other CMake project."
|
|
|
|
ON
|
2019-08-23 11:56:54 -07:00
|
|
|
)
|
|
|
|
|
|
|
|
# Dependencies : disable BUILD_DEPENDS to link with lib already build.
|
|
|
|
if(BUILD_DEPENDS)
|
2022-07-22 18:45:21 +02:00
|
|
|
|
2019-08-23 11:56:54 -07:00
|
|
|
else()
|
2022-07-22 18:45:21 +02:00
|
|
|
|
2019-08-23 11:56:54 -07:00
|
|
|
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")
|
|
|
|
endif(MSVC)
|
|
|
|
if(NOT MSVC)
|
2021-12-27 10:21:34 -05:00
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17 -fno-rtti -Wno-multichar -Wno-invalid-offsetof")
|
2019-08-23 11:56:54 -07:00
|
|
|
endif(NOT MSVC)
|
|
|
|
|
|
|
|
################ Files ################
|
|
|
|
# -- Add files to project. -- #
|
|
|
|
#######################################
|
|
|
|
|
|
|
|
file(GLOB SRC_FILES
|
2022-07-22 18:45:21 +02:00
|
|
|
BfDiff.cpp
|
2019-08-23 11:56:54 -07:00
|
|
|
Debugger.cpp
|
|
|
|
DebugManager.cpp
|
|
|
|
DebugVisualizers.cpp
|
2019-09-20 16:07:04 -07:00
|
|
|
NetManager.cpp
|
2019-08-23 11:56:54 -07:00
|
|
|
SpellChecker.cpp
|
|
|
|
Targets.cpp
|
|
|
|
X86XmmInfo.cpp
|
|
|
|
|
|
|
|
LinuxDebugger.cpp
|
2022-07-22 18:45:21 +02:00
|
|
|
|
|
|
|
Beef/BfCommon.cpp
|
2019-08-23 11:56:54 -07:00
|
|
|
Clang/CDepChecker.cpp
|
|
|
|
Clang/ClangHelper.cpp
|
|
|
|
Compiler/BfAst.cpp
|
|
|
|
Compiler/BfAstAllocator.cpp
|
|
|
|
Compiler/BfAutoComplete.cpp
|
|
|
|
Compiler/BfCodeGen.cpp
|
|
|
|
Compiler/BfCompiler.cpp
|
|
|
|
Compiler/BfConstResolver.cpp
|
|
|
|
Compiler/BfContext.cpp
|
|
|
|
Compiler/BfDefBuilder.cpp
|
|
|
|
Compiler/BfDeferEvalChecker.cpp
|
|
|
|
Compiler/BfDemangler.cpp
|
|
|
|
Compiler/BfElementVisitor.cpp
|
2020-05-31 07:51:32 -07:00
|
|
|
Compiler/BfNamespaceVisitor.cpp
|
2019-08-23 11:56:54 -07:00
|
|
|
Compiler/BfExprEvaluator.cpp
|
|
|
|
Compiler/BfIRBuilder.cpp
|
|
|
|
Compiler/BfIRCodeGen.cpp
|
|
|
|
Compiler/BfMangler.cpp
|
|
|
|
Compiler/BfModule.cpp
|
|
|
|
Compiler/BfModuleTypeUtils.cpp
|
|
|
|
Compiler/BfParser.cpp
|
|
|
|
Compiler/BfPrinter.cpp
|
|
|
|
Compiler/BfReducer.cpp
|
|
|
|
Compiler/BfResolvedTypeUtils.cpp
|
|
|
|
Compiler/BfResolvePass.cpp
|
|
|
|
Compiler/BfSource.cpp
|
|
|
|
Compiler/BfSourceClassifier.cpp
|
|
|
|
Compiler/BfSourcePositionFinder.cpp
|
|
|
|
Compiler/BfStmtEvaluator.cpp
|
|
|
|
Compiler/BfSystem.cpp
|
|
|
|
Compiler/BfUtil.cpp
|
|
|
|
Compiler/BfVarDeclChecker.cpp
|
2019-10-17 06:47:50 -07:00
|
|
|
Compiler/BfTargetTriple.cpp
|
2020-12-14 06:12:32 -08:00
|
|
|
Compiler/CeMachine.cpp
|
2022-03-17 09:39:08 -07:00
|
|
|
Compiler/CeDebugger.cpp
|
|
|
|
Compiler/MemReporter.cpp
|
2022-07-22 18:45:21 +02:00
|
|
|
|
2020-12-14 09:24:45 -08:00
|
|
|
Backend/BeContext.cpp
|
|
|
|
Backend/BeIRCodeGen.cpp
|
|
|
|
Backend/BeModule.cpp
|
2019-08-23 11:56:54 -07:00
|
|
|
)
|
|
|
|
|
2024-05-07 18:09:01 -04:00
|
|
|
find_package(LLVM 18.1 CONFIG COMPONENTS)
|
2019-08-23 11:56:54 -07:00
|
|
|
|
2024-02-16 18:40:58 -03:00
|
|
|
if (LLVM_FOUND)
|
|
|
|
message(STATUS "Found LLVM ${LLVM_PACKAGE_VERSION}")
|
|
|
|
message(STATUS "Using LLVMConfig.cmake in: ${LLVM_DIR}")
|
2020-05-21 12:55:58 -07:00
|
|
|
|
2024-02-16 18:40:58 -03:00
|
|
|
include_directories(${LLVM_INCLUDE_DIRS})
|
|
|
|
add_definitions(${LLVM_DEFINITIONS})
|
|
|
|
|
2024-05-07 18:09:01 -04:00
|
|
|
set(TARGET_LIBS_OS "-lLLVM-18 ${LLVM_SYSTEM_LIBS}")
|
2024-02-16 18:40:58 -03:00
|
|
|
else()
|
2024-05-07 18:09:01 -04:00
|
|
|
message(FATAL_ERROR "LLVM not found")
|
2022-06-27 19:37:16 -03:00
|
|
|
endif()
|
|
|
|
|
2024-02-16 18:40:58 -03:00
|
|
|
# Add library to build.
|
2024-05-07 18:09:01 -04:00
|
|
|
add_library(${PROJECT_NAME} STATIC
|
2024-02-16 18:40:58 -03:00
|
|
|
${SRC_FILES}
|
|
|
|
)
|
2020-05-21 12:55:58 -07:00
|
|
|
|
2020-05-21 13:30:30 -07:00
|
|
|
if (HAVE_BACKTRACE_HEADERS)
|
2020-05-21 14:27:55 -07:00
|
|
|
string(APPEND TARGET_LIBS_OS " -lbacktrace")
|
2022-02-08 10:38:02 -08:00
|
|
|
string(STRIP ${TARGET_LIBS_OS} TARGET_LIBS_OS)
|
2020-05-21 12:55:58 -07:00
|
|
|
endif()
|
|
|
|
|
|
|
|
if (CMAKE_BUILD_TYPE STREQUAL "Debug" )
|
|
|
|
FILE(WRITE "${CMAKE_CURRENT_SOURCE_DIR}/../IDE/dist/IDEHelper_libs_d.txt" ${TARGET_LIBS_OS})
|
2019-10-14 14:08:29 -07:00
|
|
|
else()
|
2020-05-21 12:55:58 -07:00
|
|
|
FILE(WRITE "${CMAKE_CURRENT_SOURCE_DIR}/../IDE/dist/IDEHelper_libs.txt" ${TARGET_LIBS_OS})
|
2019-10-14 14:08:29 -07:00
|
|
|
endif()
|
|
|
|
|
2019-08-23 11:56:54 -07:00
|
|
|
# Link with other dependencies.
|
|
|
|
if(MSVC)
|
2020-10-28 09:34:23 -07:00
|
|
|
target_link_libraries(${PROJECT_NAME} BeefySysLib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib LLVMX86Disassembler.lib LLVMMCDisassembler.lib LLVMSupport.lib LLVMX86Info.lib LLVMX86Desc.lib %(AdditionalDependencies) LLVMMC.lib LLVMObject.lib LLVMCore.lib LLVMBitReader.lib LLVMAsmParser.lib LLVMMCParser.lib LLVMCodeGen.lib LLVMTarget.lib LLVMX86CodeGen.lib LLVMScalarOpts.lib LLVMInstCombine.lib LLVMSelectionDAG.lib LLVMProfileData.lib LLVMTransformUtils.lib LLVMAnalysis.lib LLVMX86AsmParser.lib LLVMAsmPrinter.lib LLVMBitWriter.lib LLVMVectorize.lib LLVMipo.lib LLVMInstrumentation.lib LLVMDebugInfoDWARF.lib LLVMDebugInfoPDB.lib LLVMDebugInfoCodeView.lib LLVMGlobalISel.lib LLVMBinaryFormat.lib LLVMAggressiveInstCombine.lib libcurl_a.lib)
|
2019-08-23 11:56:54 -07:00
|
|
|
else()
|
2024-02-16 18:40:58 -03:00
|
|
|
target_link_libraries(${PROJECT_NAME} BeefySysLib hunspell pthread dl ${TARGET_LIBS_OS})
|
2019-08-23 11:56:54 -07:00
|
|
|
endif()
|