Skip to content

Commit

Permalink
add installation
Browse files Browse the repository at this point in the history
add installation

add install stage

test

fix the install file name
  • Loading branch information
tishion committed May 20, 2020
1 parent e5a1b65 commit d788d4e
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 6 deletions.
18 changes: 15 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ endif()

# Flags
# C standard
set(CMAKE_C_STANDARD_REQUIRED ON)
set(CMAKE_C_STANDARD_REQUIRED ON)
set(CMAKE_C_STANDARD 11)

# C++ standard
Expand Down Expand Up @@ -100,12 +100,24 @@ add_library(${PROJECT_NAME} STATIC
src/mmloader/mmloader.c
)

# header
set_target_properties(${PROJECT_NAME}
PROPERTIES
PUBLIC_HEADER "src/mmloader/mmloader.h"
)

# Add post build event to copy the header files
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_SOURCE_DIR}/output/mmloader/include/
COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_SOURCE_DIR}/output/mmloader/include
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_SOURCE_DIR}/src/mmloader/mmLoader.h ${CMAKE_SOURCE_DIR}/output/mmloader/include/
)

# install lib and header files
install(TARGETS ${PROJECT_NAME}
ARCHIVE DESTINATION lib
PUBLIC_HEADER DESTINATION include/mmloader
)

# Shellcode generator project
if ((NOT DEFINED BUILD_SHELLCODE_GEN) OR (BUILD_SHELLCODE_GEN STREQUAL "") OR (${BUILD_SHELLCODE_GEN} MATCHES "(FALSE|false|0|OFF)"))
option(BUILD_SHELLCODE_GEN "Generate the shellcode header files" OFF)
Expand All @@ -130,4 +142,4 @@ endif()

if (BUILD_MMLOADER_DEMO)
add_subdirectory(demo)
endif()
endif()
4 changes: 2 additions & 2 deletions demo/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
project(mmloader-demo)

if (BUILD_ARC_X8632)
set(MMLOADER_OUT ${CMAKE_SOURCE_DIR}/output/mmloader/x86)
set(MMLOADER_DEMO_OUT ${CMAKE_SOURCE_DIR}/output/demo/x86)
elseif(BUILD_ARC_X8664)
set(MMLOADER_OUT ${CMAKE_SOURCE_DIR}/output/mmloader/x64)
set(MMLOADER_DEMO_OUT ${CMAKE_SOURCE_DIR}/output/demo/x64)
else()
message(FATAL_ERROR "Unsupported Architecture")
endif()
Expand Down
1 change: 1 addition & 0 deletions gen-vc-proj.bat
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@ cmake ^
-B .build ^
-G "Visual Studio 16 2019" ^
-A Win32 ^
-DCMAKE_INSTALL_PREFIX=./pacakge ^
-DBUILD_SHELLCODE_GEN=TRUE ^
-DBUILD_MMLOADER_DEMO=TRUE
21 changes: 20 additions & 1 deletion tools/shellcode-generator/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,23 @@ target_link_options(${PROJECT_NAME} PRIVATE
# add post build event to copy the header files
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
COMMAND $<TARGET_FILE:${PROJECT_NAME}> "${CMAKE_SOURCE_DIR}\\output\\mmloader\\include\\"
)
)

# install lib and header files
install(TARGETS ${PROJECT_NAME}
RUNTIME DESTINATION tools
)

if (BUILD_ARC_X8632)
install(FILES ${CMAKE_SOURCE_DIR}/output/mmloader/include/mmLoaderShellCode-x86-Debug.h
DESTINATION include/mmloader CONFIGURATIONS Debug)
install(FILES ${CMAKE_SOURCE_DIR}/output/mmloader/include/mmLoaderShellCode-x86-Release.h
DESTINATION include/mmloader CONFIGURATIONS Release)
elseif(BUILD_ARC_X8664)
install(FILES ${CMAKE_SOURCE_DIR}/output/mmloader/include/mmLoaderShellCode-x64-Debug.h
DESTINATION include/mmloader CONFIGURATIONS Debug)
install(FILES ${CMAKE_SOURCE_DIR}/output/mmloader/include/mmLoaderShellCode-x64-Release.h
DESTINATION include/mmloader CONFIGURATIONS Release)
else()
message(FATAL_ERROR "Unsupported Architecture")
endif()

0 comments on commit d788d4e

Please sign in to comment.