mirror of
https://github.com/fancycode/MemoryModule
synced 2026-06-06 15:44:28 +00:00
Support building with cmake.
This commit is contained in:
+15
-6
@@ -1,10 +1,14 @@
|
||||
sudo: false
|
||||
|
||||
env:
|
||||
- PLATFORM=x86_64 WINE=wine64 UNICODE=
|
||||
- PLATFORM=i686 WINE=wine UNICODE=
|
||||
- PLATFORM=x86_64 WINE=wine64 UNICODE=1
|
||||
- PLATFORM=i686 WINE=wine UNICODE=1
|
||||
- PLATFORM=x86_64 WINE=wine64 UNICODE= CMAKE=
|
||||
- PLATFORM=i686 WINE=wine UNICODE= CMAKE=
|
||||
- PLATFORM=x86_64 WINE=wine64 UNICODE=1 CMAKE=
|
||||
- PLATFORM=i686 WINE=wine UNICODE=1 CMAKE=
|
||||
- PLATFORM=x86_64 WINE=wine64 UNICODE= CMAKE=1
|
||||
- PLATFORM=i686 WINE=wine UNICODE= CMAKE=1
|
||||
- PLATFORM=x86_64 WINE=wine64 UNICODE=1 CMAKE=1
|
||||
- PLATFORM=i686 WINE=wine UNICODE=1 CMAKE=1
|
||||
|
||||
language: cpp
|
||||
|
||||
@@ -17,6 +21,7 @@ addons:
|
||||
packages:
|
||||
- binutils-mingw-w64-i686
|
||||
- binutils-mingw-w64-x86-64
|
||||
- cmake
|
||||
- mingw-w64-dev
|
||||
- g++-mingw-w64-i686
|
||||
- g++-mingw-w64-x86-64
|
||||
@@ -24,9 +29,13 @@ addons:
|
||||
- gcc-mingw-w64-x86-64
|
||||
- wine
|
||||
|
||||
before_script:
|
||||
- if [ ! -z "$CMAKE" ]; then cmake -DPLATFORM=$PLATFORM -D UNICODE=$UNICODE -H. -B.; fi
|
||||
|
||||
script:
|
||||
- make PLATFORM=$PLATFORM UNICODE=$UNICODE
|
||||
- make test PLATFORM=$PLATFORM UNICODE=$UNICODE
|
||||
- if [ -z "$CMAKE" ]; then make PLATFORM=$PLATFORM UNICODE=$UNICODE; fi
|
||||
- if [ -z "$CMAKE" ]; then make test PLATFORM=$PLATFORM UNICODE=$UNICODE; fi
|
||||
- if [ ! -z "$CMAKE" ]; then cmake --build .; fi
|
||||
- cd example/DllLoader
|
||||
- WINEPREFIX=`pwd`/$WINE WINEPATH=/usr/lib/gcc/$PLATFORM-w64-mingw32/4.6/ $WINE ./DllLoader.exe
|
||||
- WINEPREFIX=`pwd`/$WINE WINEPATH=/usr/lib/gcc/$PLATFORM-w64-mingw32/4.6/ $WINE ./DllLoaderLoader.exe
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
project (MemoryModule)
|
||||
cmake_minimum_required (VERSION 2.8.7)
|
||||
|
||||
set (PLATFORM "x86_64" CACHE STRING "Platform to compile for")
|
||||
message (STATUS "Compile for ${PLATFORM} platform")
|
||||
|
||||
if (NOT MSVC)
|
||||
set (CMAKE_SYSTEM_NAME Windows)
|
||||
set (CMAKE_POSITION_INDEPENDENT_CODE False)
|
||||
|
||||
set (COMPILER_PREFIX "${PLATFORM}-w64-mingw32")
|
||||
set (CMAKE_C_COMPILER "${COMPILER_PREFIX}-gcc")
|
||||
set (CMAKE_CXX_COMPILER "${COMPILER_PREFIX}-g++")
|
||||
set (CMAKE_RC_COMPILER "${COMPILER_PREFIX}-windres")
|
||||
set (CMAKE_AR "${COMPILER_PREFIX}-ar")
|
||||
set (CMAKE_RANLIB "${COMPILER_PREFIX}-ranlib")
|
||||
|
||||
set (CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
|
||||
set (CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
|
||||
set (CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
|
||||
|
||||
set (CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "")
|
||||
set (CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS "")
|
||||
|
||||
set (CMAKE_RC_COMPILE_OBJECT "${CMAKE_RC_COMPILER} -O coff -I${CMAKE_CURRENT_SOURCE_DIR} <SOURCE> <OBJECT>")
|
||||
endif ()
|
||||
|
||||
add_definitions ("-Wall")
|
||||
|
||||
option(UNICODE "Compile with UNICODE support" OFF)
|
||||
if (UNICODE)
|
||||
message (STATUS "Compile with UNICODE support")
|
||||
add_definitions ("-DUNICODE" "-D_UNICODE")
|
||||
else ()
|
||||
message (STATUS "Compile without UNICODE support")
|
||||
endif ()
|
||||
|
||||
add_library (MemoryModule STATIC MemoryModule.c MemoryModule.h)
|
||||
if (NOT MSVC)
|
||||
set_target_properties ("MemoryModule" PROPERTIES PREFIX "")
|
||||
endif ()
|
||||
|
||||
add_subdirectory (example)
|
||||
|
||||
enable_language (RC)
|
||||
@@ -0,0 +1,2 @@
|
||||
add_subdirectory (DllLoader)
|
||||
add_subdirectory (SampleDLL)
|
||||
@@ -0,0 +1,26 @@
|
||||
set (sources_dllloader
|
||||
DllLoader.cpp
|
||||
)
|
||||
|
||||
set (sources_dllloaderloader
|
||||
DllLoaderLoader.cpp
|
||||
)
|
||||
|
||||
if (NOT MSVC)
|
||||
set (CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "-static")
|
||||
set (CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS "-static")
|
||||
endif ()
|
||||
|
||||
add_executable (DllLoader ${sources_dllloader})
|
||||
target_link_libraries ("DllLoader" "MemoryModule")
|
||||
if (NOT MSVC)
|
||||
set_target_properties ("DllLoader" PROPERTIES SUFFIX ".exe")
|
||||
set_target_properties ("DllLoader" PROPERTIES LINK_FLAGS "-Wl,--image-base -Wl,0x20000000")
|
||||
endif ()
|
||||
|
||||
add_executable (DllLoaderLoader ${sources_dllloaderloader})
|
||||
target_link_libraries ("DllLoaderLoader" "MemoryModule")
|
||||
if (NOT MSVC)
|
||||
set_target_properties ("DllLoaderLoader" PROPERTIES SUFFIX ".exe")
|
||||
set_target_properties ("DllLoaderLoader" PROPERTIES LINK_FLAGS "-Wl,--image-base -Wl,0x10000000")
|
||||
endif ()
|
||||
@@ -0,0 +1,12 @@
|
||||
set (sources
|
||||
SampleDLL.cpp
|
||||
SampleDLL.h
|
||||
SampleDLL.rc
|
||||
)
|
||||
|
||||
add_definitions (-DSAMPLEDLL_EXPORTS)
|
||||
add_library (SampleDLL MODULE ${sources})
|
||||
if (NOT MSVC)
|
||||
set_target_properties ("SampleDLL" PROPERTIES PREFIX "")
|
||||
set_target_properties ("SampleDLL" PROPERTIES SUFFIX ".dll")
|
||||
endif ()
|
||||
Reference in New Issue
Block a user