diff --git a/BMap/CMakeLists.txt b/BMap/CMakeLists.txt new file mode 100644 index 0000000..7f4d8b6 --- /dev/null +++ b/BMap/CMakeLists.txt @@ -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 +) + diff --git a/IronPad/CMakeLists.txt b/IronPad/CMakeLists.txt index 5452976..6bdf334 100644 --- a/IronPad/CMakeLists.txt +++ b/IronPad/CMakeLists.txt @@ -1,11 +1,10 @@ cmake_minimum_required(VERSION 3.12) project(IronPad LANGUAGES CXX) -# set standard -set(CMAKE_CXX_STANDARD 20) - -# add libcmo -add_subdirectory("../LibCmo" "LibCmo.out") +# add libcmo if not existed +if (NOT TARGET LibCmo) + add_subdirectory("../LibCmo" "LibCmo.out") +endif () # setup sources set(ironpad_headers ".") @@ -24,3 +23,11 @@ target_include_directories(IronPad PUBLIC ${ironpad_headers} ) + +# set project standard +set_target_properties(IronPad +PROPERTIES + CXX_STANDARD 20 + CXX_STANDARD_REQUIRED 20 + CXX_EXTENSION OFF +) diff --git a/IronPad/IronPad.cpp b/IronPad/IronPad.cpp index bcadaa6..dd4aeff 100644 --- a/IronPad/IronPad.cpp +++ b/IronPad/IronPad.cpp @@ -1,9 +1,14 @@ #include "IronPad.hpp" + +// only include these header on windows. +// in other words, include these header when ironpad enabled. +#if defined(IRONPAD_ENABLED) #include #include #include #include #include +#endif namespace IronPad { diff --git a/LibCmo/CMakeLists.txt b/LibCmo/CMakeLists.txt index d0beebe..9fe30dc 100644 --- a/LibCmo/CMakeLists.txt +++ b/LibCmo/CMakeLists.txt @@ -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.") endif () -# set standard -set(CMAKE_CXX_STANDARD 20) - +# set up file list set(libcmo_headers ".") set(libcmo_vt_src @@ -84,7 +82,14 @@ PRIVATE ${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 PUBLIC $<$:LIBCMO_BUILD_DEBUG> diff --git a/LibCmo/VTUtils.hpp b/LibCmo/VTUtils.hpp index 1a34c02..6156bff 100644 --- a/LibCmo/VTUtils.hpp +++ b/LibCmo/VTUtils.hpp @@ -1,7 +1,7 @@ #pragma once -#if !defined(LIBCMO_BUILD_DEBUG) && !defined(LIBCMO_BUILD_RELEASE) -#error "You must define LIBCMO_BUILD_DEBUG or LIBCMO_BUILD_RELEASE to indicate build type!" +#if !(defined(LIBCMO_BUILD_DEBUG) ^ defined(LIBCMO_BUILD_RELEASE)) +#error "You must define ONE of LIBCMO_BUILD_DEBUG and LIBCMO_BUILD_RELEASE to indicate build type!" #endif // https://stackoverflow.com/questions/2164827/explicitly-exporting-shared-library-functions-in-linux diff --git a/Unvirt/CMakeLists.txt b/Unvirt/CMakeLists.txt index c3ba74a..f015313 100644 --- a/Unvirt/CMakeLists.txt +++ b/Unvirt/CMakeLists.txt @@ -1,15 +1,17 @@ cmake_minimum_required(VERSION 3.12) project(Unvirt LANGUAGES CXX) -# set languages -set(CMAKE_CXX_STANDARD 20) - -# add libcmo -add_subdirectory("../LibCmo" "LibCmo.out") -# add ironpad -#add_subdirectory("../IronPad" "IronPad.out") +# 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 () # setup sources +set(unvirt_headers ".") set(unvirt_sources AccessibleValue.cpp CmdHelper.cpp @@ -27,4 +29,17 @@ PRIVATE LibCmo 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 +) +