fix cmake build issue. fix build type checker. rm IronPad windows header including under linux

This commit is contained in:
yyc12345 2023-09-25 21:45:53 +08:00
parent 8083633a7b
commit 0a168ac5cc
6 changed files with 115 additions and 18 deletions

65
BMap/CMakeLists.txt Normal file
View File

@ -0,0 +1,65 @@
cmake_minimum_required(VERSION 3.12)
project(BMap LANGUAGES CXX)
# add libcmo if not existed
if (NOT TARGET LibCmo)
add_subdirectory("../LibCmo" "LibCmo.out")
endif ()
# add ironpad if not existed
if (NOT TARGET IronPad)
add_subdirectory("../IronPad" "IronPad.out")
endif ()
# hide all function in default
# fix imported library PIC issue (i don't know why. just make it works)
set_target_properties(LibCmo
PROPERTIES
CXX_VISIBILITY_PRESET hidden
POSITION_INDEPENDENT_CODE ON
)
set_target_properties(IronPad
PROPERTIES
CXX_VISIBILITY_PRESET hidden
POSITION_INDEPENDENT_CODE ON
)
# setup sources
set(bmap_headers ".")
set(bmap_sources
BMap.cpp
BMExports.cpp
)
# generate shared library
add_library(BMap
SHARED
${bmap_sources}
)
target_link_libraries(BMap
PRIVATE
LibCmo
IronPad
)
target_include_directories(BMap
PRIVATE
${bmap_headers}
)
# set project standard
set_target_properties(BMap
PROPERTIES
CXX_STANDARD 20
CXX_STANDARD_REQUIRED 20
CXX_EXTENSION OFF
)
# set default visibility to hidden
set_target_properties(BMap
PROPERTIES
CXX_VISIBILITY_PRESET hidden
)
# add export used macro flag
target_compile_definitions(BMap
PUBLIC
LIBCMO_EXPORTING
)

View File

@ -1,11 +1,10 @@
cmake_minimum_required(VERSION 3.12) cmake_minimum_required(VERSION 3.12)
project(IronPad LANGUAGES CXX) project(IronPad LANGUAGES CXX)
# set standard # add libcmo if not existed
set(CMAKE_CXX_STANDARD 20) if (NOT TARGET LibCmo)
add_subdirectory("../LibCmo" "LibCmo.out")
# add libcmo endif ()
add_subdirectory("../LibCmo" "LibCmo.out")
# setup sources # setup sources
set(ironpad_headers ".") set(ironpad_headers ".")
@ -24,3 +23,11 @@ target_include_directories(IronPad
PUBLIC PUBLIC
${ironpad_headers} ${ironpad_headers}
) )
# set project standard
set_target_properties(IronPad
PROPERTIES
CXX_STANDARD 20
CXX_STANDARD_REQUIRED 20
CXX_EXTENSION OFF
)

View File

@ -1,9 +1,14 @@
#include "IronPad.hpp" #include "IronPad.hpp"
// only include these header on windows.
// in other words, include these header when ironpad enabled.
#if defined(IRONPAD_ENABLED)
#include <Windows.h> #include <Windows.h>
#include <DbgHelp.h> #include <DbgHelp.h>
#include <filesystem> #include <filesystem>
#include <cstdarg> #include <cstdarg>
#include <cstdio> #include <cstdio>
#endif
namespace IronPad { namespace IronPad {

View File

@ -13,9 +13,7 @@ if ((NOT EXISTS "${STB_IMAGE_PATH}/stb_image.h") OR (NOT EXISTS "${STB_IMAGE_PAT
message(FATAL_ERROR "Invalid stb_image library path.") message(FATAL_ERROR "Invalid stb_image library path.")
endif () endif ()
# set standard # set up file list
set(CMAKE_CXX_STANDARD 20)
set(libcmo_headers ".") set(libcmo_headers ".")
set(libcmo_vt_src set(libcmo_vt_src
@ -84,7 +82,14 @@ PRIVATE
${Iconv_INCLUDE_DIRS} ${Iconv_INCLUDE_DIRS}
) )
# add essential build macro # set project standard
set_target_properties(LibCmo
PROPERTIES
CXX_STANDARD 20
CXX_STANDARD_REQUIRED 20
CXX_EXTENSION OFF
)
# add essential build macro and populate them
target_compile_definitions(LibCmo target_compile_definitions(LibCmo
PUBLIC PUBLIC
$<$<CONFIG:Debug>:LIBCMO_BUILD_DEBUG> $<$<CONFIG:Debug>:LIBCMO_BUILD_DEBUG>

View File

@ -1,7 +1,7 @@
#pragma once #pragma once
#if !defined(LIBCMO_BUILD_DEBUG) && !defined(LIBCMO_BUILD_RELEASE) #if !(defined(LIBCMO_BUILD_DEBUG) ^ defined(LIBCMO_BUILD_RELEASE))
#error "You must define LIBCMO_BUILD_DEBUG or LIBCMO_BUILD_RELEASE to indicate build type!" #error "You must define ONE of LIBCMO_BUILD_DEBUG and LIBCMO_BUILD_RELEASE to indicate build type!"
#endif #endif
// https://stackoverflow.com/questions/2164827/explicitly-exporting-shared-library-functions-in-linux // https://stackoverflow.com/questions/2164827/explicitly-exporting-shared-library-functions-in-linux

View File

@ -1,15 +1,17 @@
cmake_minimum_required(VERSION 3.12) cmake_minimum_required(VERSION 3.12)
project(Unvirt LANGUAGES CXX) project(Unvirt LANGUAGES CXX)
# set languages # add libcmo if not existed
set(CMAKE_CXX_STANDARD 20) if (NOT TARGET LibCmo)
add_subdirectory("../LibCmo" "LibCmo.out")
# add libcmo endif ()
add_subdirectory("../LibCmo" "LibCmo.out") # add ironpad if not existed
# add ironpad if (NOT TARGET IronPad)
#add_subdirectory("../IronPad" "IronPad.out") add_subdirectory("../IronPad" "IronPad.out")
endif ()
# setup sources # setup sources
set(unvirt_headers ".")
set(unvirt_sources set(unvirt_sources
AccessibleValue.cpp AccessibleValue.cpp
CmdHelper.cpp CmdHelper.cpp
@ -27,4 +29,17 @@ PRIVATE
LibCmo LibCmo
IronPad IronPad
) )
target_include_directories(Unvirt
PRIVATE
${unvirt_headers}
)
# set project standard
set_target_properties(Unvirt
PROPERTIES
CXX_STANDARD 20
CXX_STANDARD_REQUIRED 20
CXX_EXTENSION OFF
)