use cmake option to support build and cross-build

This commit is contained in:
lyon 2022-05-05 21:38:19 +08:00
parent 31f58e9baf
commit 995f674fef
5 changed files with 19 additions and 32 deletions

View File

@ -13,9 +13,21 @@ add_executable(pikaByteCodeGen main.c
${pikascript-core}
)
target_link_libraries(pikaByteCodeGen
pikabinder
)
OPTION(CROSS_COMPILE "cross-compile" OFF)
IF(CROSS_COMPILE)
target_link_libraries(pikaByteCodeGen
pikabinder
ws2_32
bcrypt
user32
userenv
)
ELSE(CROSS_COMPILE)
target_link_libraries(pikaByteCodeGen
pikabinder
)
ENDIF(CROSS_COMPILE)
set(CPACK_PROJECT_NAME ${PROJECT_NAME})
set(CPACK_PROJECT_VERSION ${PROJECT_VERSION})

View File

@ -1,27 +0,0 @@
cmake_minimum_required(VERSION 3.0.0)
project(pikaByteCodeGen VERSION 0.1.0)
include(CTest)
enable_testing()
aux_source_directory(pikascript/pikascript-core pikascript-core)
include_directories(pikascript/pikascript-core)
include_directories(libpikabinder)
link_directories(libpikabinder)
add_executable(pikaByteCodeGen main.c
${pikascript-core}
)
target_link_libraries(pikaByteCodeGen
bcrypt
user32
userenv
ws2_32
wsock32
pikabinder
)
set(CPACK_PROJECT_NAME ${PROJECT_NAME})
set(CPACK_PROJECT_VERSION ${PROJECT_VERSION})
include(CPack)

View File

@ -1 +1,3 @@
rm build-win -rf && mkdir build-win && cd build-win && cmake -DCMAKE_TOOLCHAIN_FILE=../CrossCompile.cmake .. && make -j
rm build-win -rf && \
mkdir build-win && \
cd build-win && cmake -DCMAKE_TOOLCHAIN_FILE=../CrossCompile.cmake -DCROSS_COMPILE=ON .. && make -j

View File

@ -14,6 +14,6 @@ cp ../../src pikascript/pikascript-core -r
sh cross-win.sh
cp pikaByteCodeGen $ROOT/rust-msc-latest-linux
cp build-win/pikaByteCodeGen.exe $ROOT/rust-msc-latest-win10.exe
cd $ROOT
chmod +x rust-msc-latest-linux