diff --git a/CMakeLists.txt b/CMakeLists.txt index 3f1bb41..a3b8507 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -16,12 +16,14 @@ set(CMAKE_OPTIMIZE_DEPENDENCIES ON) include(GNUInstallDirs) -include("${CMAKE_CURRENT_SOURCE_DIR}/cmake/CPM.cmake") +include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/CPM.cmake) + +set(CPM_SOURCE_CACHE ${CMAKE_CURRENT_BINARY_DIR}/.cpm) CPMAddPackage("gh:Starfield-Reverse-Engineering/CommonLibSF#main") CPMAddPackage("gh:brofield/simpleini@4.20") -include("${CommonLibSF_SOURCE_DIR}/CommonLibSF/cmake/CommonLibSF.cmake") +include(${CommonLibSF_SOURCE_DIR}/CommonLibSF/cmake/CommonLibSF.cmake) configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/cmake/version.rc.in @@ -29,7 +31,7 @@ configure_file( @ONLY ) -set(PUBLIC_HEADER_DIR "${CMAKE_CURRENT_SOURCE_DIR}/include/${PROJECT_NAME}") +set(PUBLIC_HEADER_DIR ${CMAKE_CURRENT_SOURCE_DIR}/include/${PROJECT_NAME}) set( headers @@ -59,7 +61,7 @@ add_commonlibsf_plugin( SOURCES ${headers} ${sources} ) -add_library("${PROJECT_NAME}::${PROJECT_NAME}" ALIAS "${PROJECT_NAME}") +add_library(${PROJECT_NAME}::${PROJECT_NAME} ALIAS ${PROJECT_NAME}) target_include_directories( ${PROJECT_NAME} @@ -80,61 +82,41 @@ target_precompile_headers( ) install( - DIRECTORY "${PUBLIC_HEADER_DIR}" - DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}" + DIRECTORY ${PUBLIC_HEADER_DIR} + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} ) install( TARGETS ${PROJECT_NAME} - DESTINATION "${CMAKE_INSTALL_LIBDIR}" + DESTINATION ${CMAKE_INSTALL_LIBDIR} ) ######################################################################################################################## ## Automatic plugin deployment ######################################################################################################################## -if(CMAKE_BUILD_TYPE STREQUAL "Debug") - set(BUILD_NAME "Debug") +if(CMAKE_BUILD_TYPE STREQUAL Debug) + set(BUILD_NAME Debug) else() - set(BUILD_NAME "Release") + set(BUILD_NAME Release) endif() add_custom_command( TARGET ${PROJECT_NAME} POST_BUILD COMMAND - ${CMAKE_COMMAND} -E make_directory "${CMAKE_CURRENT_SOURCE_DIR}/contrib/Plugin${BUILD_NAME}/sfse/plugins" -) -add_custom_command( - TARGET ${PROJECT_NAME} - POST_BUILD + ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_SOURCE_DIR}/contrib/Plugin${BUILD_NAME}/sfse/plugins COMMAND - ${CMAKE_COMMAND} -E copy $ "${CMAKE_CURRENT_SOURCE_DIR}/contrib/Plugin${BUILD_NAME}/sfse/plugins" -) -add_custom_command( - TARGET ${PROJECT_NAME} - POST_BUILD + ${CMAKE_COMMAND} -E copy $ ${CMAKE_CURRENT_SOURCE_DIR}/contrib/Plugin${BUILD_NAME}/sfse/plugins COMMAND - ${CMAKE_COMMAND} -E copy $ "${CMAKE_CURRENT_SOURCE_DIR}/contrib/Plugin${BUILD_NAME}/sfse/plugins" -) -add_custom_command( - TARGET ${PROJECT_NAME} - POST_BUILD + ${CMAKE_COMMAND} -E copy $ ${CMAKE_CURRENT_SOURCE_DIR}/contrib/Plugin${BUILD_NAME}/sfse/plugins COMMAND - ${CMAKE_COMMAND} -E copy "${CMAKE_CURRENT_SOURCE_DIR}/contrib/Config/${PROJECT_NAME}.ini" "${CMAKE_CURRENT_SOURCE_DIR}/contrib/Plugin${BUILD_NAME}/sfse/plugins" + ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/contrib/Config/${PROJECT_NAME}.ini ${CMAKE_CURRENT_SOURCE_DIR}/contrib/Plugin${BUILD_NAME}/sfse/plugins ) -file(GLOB_RECURSE OUTPUT_DLLS "${CMAKE_CURRENT_SOURCE_DIR}/contrib/**/*.dll") -file(GLOB_RECURSE OUTPUT_PDBS "${CMAKE_CURRENT_SOURCE_DIR}/contrib/**/*.pdb") +file(GLOB_RECURSE OUTPUT_DLLS ${CMAKE_CURRENT_SOURCE_DIR}/contrib/**/*.dll) +file(GLOB_RECURSE OUTPUT_PDBS ${CMAKE_CURRENT_SOURCE_DIR}/contrib/**/*.pdb) set_property( TARGET ${PROJECT_NAME} - APPEND PROPERTY ADDITIONAL_CLEAN_FILES "${OUTPUT_DLLS}" -) -set_property( - TARGET ${PROJECT_NAME} - APPEND PROPERTY ADDITIONAL_CLEAN_FILES "${OUTPUT_PDBS}" -) -set_property( - TARGET ${PROJECT_NAME} - APPEND PROPERTY ADDITIONAL_CLEAN_FILES "${CMAKE_CURRENT_SOURCE_DIR}/build/.cpm" + APPEND PROPERTY ADDITIONAL_CLEAN_FILES ${OUTPUT_DLLS} ${OUTPUT_PDBS} ${CPM_SOURCE_CACHE} ${CMAKE_CURRENT_BINARY_DIR}/_deps ) diff --git a/CMakePresets.json b/CMakePresets.json index ed16137..01c1937 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -12,8 +12,7 @@ "cacheVariables": { "CMAKE_CXX_FLAGS": "$env{COMMONLIBSF_COMPILER} $env{COMMONLIBSF_PLATFORM} $penv{CXXFLAGS}", "CMAKE_SHARED_LINKER_FLAGS": "$env{COMMONLIBSF_LINKER} $penv{SHARED_LINKER_FLAGS}", - "CMAKE_MSVC_RUNTIME_LIBRARY": "MultiThreaded$<$:Debug>DLL", - "CPM_SOURCE_CACHE": "${sourceDir}/build/.cpm" + "CMAKE_MSVC_RUNTIME_LIBRARY": "MultiThreaded$<$:Debug>DLL" } }, {