mirror of
https://github.com/cemu-project/vcpkg.git
synced 2025-02-23 02:57:09 +01:00
[cunit] Refactor CMake to perform proper installation
This commit is contained in:
parent
beda0c3832
commit
f22475aad9
@ -1,22 +1,31 @@
|
||||
cmake_minimum_required (VERSION 3.8.0)
|
||||
project (libcunit C CXX)
|
||||
set(CMAKE_CXX_STANDARD 11)
|
||||
project (libcunit C)
|
||||
|
||||
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
|
||||
set(HEADERS_DIR "${PROJECT_SOURCE_DIR}/CUnit/Headers")
|
||||
set(SOURCES_DIR "${PROJECT_SOURCE_DIR}/CUnit/Sources")
|
||||
set(EXAMPLES_DIR "${PROJECT_SOURCE_DIR}/Examples")
|
||||
|
||||
if(MSVC)
|
||||
add_compile_options(/W3 /wd4005 /wd4996 -D_CRT_SECURE_NO_WARNINGS)
|
||||
endif()
|
||||
|
||||
configure_file(
|
||||
"${HEADERS_DIR}/CUnit.h.in"
|
||||
"${PROJECT_BINARY_DIR}/CUnit.h"
|
||||
)
|
||||
|
||||
file(READ "${PROJECT_BINARY_DIR}/CUnit.h" CUNIT_H)
|
||||
if (BUILD_SHARED_LIBS)
|
||||
string(REPLACE "ifdef CU_DLL" "if 1" CUNIT_H "${CUNIT_H}")
|
||||
else()
|
||||
string(REPLACE "ifdef CU_DLL" "if 0" CUNIT_H "${CUNIT_H}")
|
||||
endif()
|
||||
file(WRITE "${PROJECT_BINARY_DIR}/CUnit.h" "${CUNIT_H}")
|
||||
|
||||
include_directories("${PROJECT_BINARY_DIR}")
|
||||
include_directories(${HEADERS_DIR})
|
||||
include_directories(${EXAMPLES_DIR})
|
||||
|
||||
file(GLOB TARGET_SRC
|
||||
add_library(libcunit
|
||||
"${SOURCES_DIR}/Automated/Automated.c"
|
||||
"${SOURCES_DIR}/Basic/Basic.c"
|
||||
"${SOURCES_DIR}/Console/Console.c"
|
||||
@ -26,17 +35,26 @@ file(GLOB TARGET_SRC
|
||||
"${SOURCES_DIR}/Framework/TestRun.c"
|
||||
"${SOURCES_DIR}/Framework/Util.c"
|
||||
)
|
||||
target_compile_definitions(libcunit PRIVATE -DCU_BUILD_DLL)
|
||||
|
||||
add_library(libcunit SHARED ${TARGET_SRC})
|
||||
if(BUILD_EXAMPLES)
|
||||
include_directories(${EXAMPLES_DIR})
|
||||
add_executable(AutomatedTest ${EXAMPLES_DIR}/AutomatedTest/AutomatedTest.c "${EXAMPLES_DIR}/ExampleTests.c")
|
||||
add_executable(BasicTest ${EXAMPLES_DIR}/BasicTest/BasicTest.c "${EXAMPLES_DIR}/ExampleTests.c")
|
||||
add_executable(ConsoleTest ${EXAMPLES_DIR}/ConsoleTest/ConsoleTest.c "${EXAMPLES_DIR}/ExampleTests.c")
|
||||
|
||||
if (MSVC)
|
||||
add_definitions( "/W3 /D_CRT_SECURE_NO_WARNINGS /wd4005 /wd4996 /nologo /DCU_BUILD_DLL /DCU_DLL" )
|
||||
target_link_libraries(AutomatedTest libcunit)
|
||||
target_link_libraries(BasicTest libcunit)
|
||||
target_link_libraries(ConsoleTest libcunit)
|
||||
endif()
|
||||
|
||||
add_executable(AutomatedTest ${EXAMPLES_DIR}/AutomatedTest/AutomatedTest.c "${EXAMPLES_DIR}/ExampleTests.c")
|
||||
add_executable(BasicTest ${EXAMPLES_DIR}/BasicTest/BasicTest.c "${EXAMPLES_DIR}/ExampleTests.c")
|
||||
add_executable(ConsoleTest ${EXAMPLES_DIR}/ConsoleTest/ConsoleTest.c "${EXAMPLES_DIR}/ExampleTests.c")
|
||||
install(
|
||||
TARGETS libcunit
|
||||
RUNTIME DESTINATION bin
|
||||
LIBRARY DESTINATION lib
|
||||
ARCHIVE DESTINATION lib
|
||||
)
|
||||
|
||||
target_link_libraries(AutomatedTest libcunit)
|
||||
target_link_libraries(BasicTest libcunit)
|
||||
target_link_libraries(ConsoleTest libcunit)
|
||||
if(NOT DISABLE_INSTALL_HEADERS)
|
||||
install(DIRECTORY "${HEADERS_DIR}/" DESTINATION include/cunit FILES_MATCHING PATTERN "*.h")
|
||||
endif()
|
@ -1,3 +1,3 @@
|
||||
Source: cunit
|
||||
Version: 2.1.3
|
||||
Version: 2.1.3-1
|
||||
Description: CUnit is a lightweight system for writing, administering, and running unit tests in C. It provides C programmers a basic testing functionality with a flexible variety of user interfaces
|
||||
|
@ -8,51 +8,16 @@ vcpkg_download_distfile(ARCHIVE
|
||||
)
|
||||
vcpkg_extract_source_archive(${ARCHIVE})
|
||||
|
||||
vcpkg_execute_required_process(COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_LIST_DIR}/CMakeLists.txt ${SOURCE_PATH}/CMakeLists.txt WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR})
|
||||
|
||||
file(COPY ${CMAKE_CURRENT_LIST_DIR}/CMakeLists.txt DESTINATION ${SOURCE_PATH})
|
||||
|
||||
vcpkg_configure_cmake(
|
||||
SOURCE_PATH ${SOURCE_PATH}
|
||||
PREFER_NINJA
|
||||
OPTIONS_DEBUG -DDISABLE_INSTALL_HEADERS=ON
|
||||
)
|
||||
|
||||
vcpkg_build_cmake()
|
||||
vcpkg_install_cmake()
|
||||
|
||||
file(GLOB HEADERS "${SOURCE_PATH}/CUnit/Headers/*.h")
|
||||
file(INSTALL ${HEADERS} DESTINATION ${CURRENT_PACKAGES_DIR}/include/cunit)
|
||||
file(INSTALL ${SOURCE_PATH}/COPYING DESTINATION ${CURRENT_PACKAGES_DIR}/share/cunit RENAME copyright)
|
||||
|
||||
|
||||
file(GLOB DLLS
|
||||
"${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel/*.dll"
|
||||
"${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel/Release/*.dll"
|
||||
"${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel/*/Release/*.dll"
|
||||
)
|
||||
file(GLOB LIBS
|
||||
"${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel/*.lib"
|
||||
"${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel/Release/*.lib"
|
||||
"${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel/*/Release/*.lib"
|
||||
)
|
||||
file(GLOB DEBUG_DLLS
|
||||
"${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg/*.dll"
|
||||
"${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg/Debug/*.dll"
|
||||
"${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg/*/Debug/*.dll"
|
||||
)
|
||||
file(GLOB DEBUG_LIBS
|
||||
"${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg/*.lib"
|
||||
"${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg/Debug/*.lib"
|
||||
"${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg/*/Debug/*.lib"
|
||||
)
|
||||
|
||||
if(DLLS)
|
||||
file(INSTALL ${DLLS} DESTINATION ${CURRENT_PACKAGES_DIR}/bin)
|
||||
endif()
|
||||
file(INSTALL ${LIBS} DESTINATION ${CURRENT_PACKAGES_DIR}/lib)
|
||||
if(DEBUG_DLLS)
|
||||
file(INSTALL ${DEBUG_DLLS} DESTINATION ${CURRENT_PACKAGES_DIR}/debug/bin)
|
||||
endif()
|
||||
file(INSTALL ${DEBUG_LIBS} DESTINATION ${CURRENT_PACKAGES_DIR}/debug/lib)
|
||||
|
||||
if(VCPKG_LIBRARY_LINKAGE STREQUAL static)
|
||||
file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/bin ${CURRENT_PACKAGES_DIR}/debug/bin)
|
||||
endif()
|
||||
vcpkg_copy_pdbs()
|
||||
|
Loading…
x
Reference in New Issue
Block a user