-
Notifications
You must be signed in to change notification settings - Fork 288
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This commit adds an option to build using CMake by adding CMakeLists.txt. CMake builds are consistent with the builds currently produced. For Linux build, CPack produces artifacts consistent with the current RPM specification. CMake is also added to the CI pipeline in main.yml.
- Loading branch information
Showing
10 changed files
with
410 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,129 @@ | ||
cmake_minimum_required(VERSION 3.13) | ||
|
||
# Allow CMake 3.13+ to override options when using FetchContent/add_subdirectory. | ||
# option honors normal variables | ||
if (POLICY CMP0077) | ||
cmake_policy(SET CMP0077 NEW) | ||
endif() | ||
|
||
# INTERFACE_LINK_LIBRARIES defines the link interface. | ||
if (POLICY CMP0022) | ||
cmake_policy (SET CMP0022 NEW) | ||
endif() | ||
|
||
# PICT version, build, and product info | ||
set(PICT_VERSION_MAJOR 3 CACHE STRING "PICT major version") | ||
set(PICT_VERSION_MINOR 7 CACHE STRING "PICT minor version") | ||
set(PICT_VERSION_BUILD 3 CACHE STRING "PICT build version") | ||
set(PICT_VERSION_SHORT "${PICT_VERSION_MAJOR}.${PICT_VERSION_MINOR}") | ||
set(PICT_VERSION_FULL "${PICT_VERSION_SHORT}.${PICT_VERSION_BUILD}") | ||
|
||
message(STATUS "PICT version ${PICT_VERSION_FULL}") | ||
|
||
# Set project name and properties | ||
project( | ||
PICT | ||
DESCRIPTION "Pairwise Independent Combinatorial Tool" | ||
HOMEPAGE_URL "https://github.com/microsoft/pict" | ||
LANGUAGES CXX | ||
VERSION ${PICT_VERSION_FULL} | ||
) | ||
|
||
# Build configuration | ||
option(PICT_RUN_TESTS_ENABLED "Enable running tests after build" ON) | ||
|
||
set(CMAKE_CXX_STANDARD 17) | ||
set(CMAKE_CXX_EXTENSIONS OFF) | ||
set(CMAKE_DISABLE_PRECOMPILE_HEADERS ON) | ||
set_property(GLOBAL PROPERTY USE_FOLDERS ON) | ||
|
||
set(PICT_BUILD_OPTIONS PictBuildOptions) | ||
add_library(${PICT_BUILD_OPTIONS} | ||
INTERFACE | ||
) | ||
|
||
if (MSVC) | ||
# Enable multi-threaded build with MSVC | ||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP") | ||
target_compile_options(${PICT_BUILD_OPTIONS} | ||
INTERFACE | ||
/W3 | ||
) | ||
|
||
target_compile_definitions(${PICT_BUILD_OPTIONS} | ||
INTERFACE | ||
UNICODE | ||
WIN32_LEAN_AND_MEAN | ||
) | ||
else() | ||
target_compile_options(${PICT_BUILD_OPTIONS} | ||
INTERFACE | ||
-fPIC # Position-independent code: necessary for static libraries that are linked in dynamic libraries | ||
-pipe | ||
-fno-omit-frame-pointer | ||
-fvisibility=hidden # By default, hide symbols on ELF binaries | ||
-g # add debug symbols for build pdb | ||
) | ||
|
||
# AppleClang is not accepting -flto as linker option | ||
if(NOT APPLE) | ||
target_link_options(${PICT_BUILD_OPTIONS} | ||
INTERFACE | ||
$<IF:$<CONFIG:Debug>,,LINKER:-flto$<COMMA>-flto-partition=none> #Enable LTO | ||
$<IF:$<CONFIG:Debug>,,LINKER:--no-undefined> # Have Linker error out if any symbols are undefined. | ||
) | ||
endif() | ||
endif() | ||
|
||
target_compile_definitions(${PICT_BUILD_OPTIONS} | ||
INTERFACE | ||
$<IF:$<CONFIG:Debug>,_DEBUG,NDEBUG> | ||
) | ||
|
||
add_subdirectory (api) | ||
add_subdirectory (cli) | ||
add_subdirectory (clidll) | ||
|
||
if(PICT_RUN_TESTS_ENABLED) | ||
enable_testing() | ||
add_subdirectory(test) | ||
endif() | ||
|
||
if(WIN32) | ||
add_subdirectory(api-usage) | ||
add_subdirectory(clidll-usage) | ||
endif() | ||
|
||
if(WIN32) | ||
set(CPACK_GENERATOR ZIP NUGET) | ||
else() | ||
set(CPACK_GENERATOR TGZ) | ||
endif() | ||
|
||
set(CPACK_SOURCE_GENERATOR "TGZ") | ||
set(CPACK_SOURCE_IGNORE_FILES | ||
\\.git/ | ||
build/ | ||
".*~$" | ||
) | ||
set(CPACK_VERBATIM_VARIABLES YES) | ||
|
||
execute_process( | ||
COMMAND git log --pretty=format:%H -n 1 | ||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} | ||
OUTPUT_VARIABLE GIT_COMMIT_HASH | ||
OUTPUT_STRIP_TRAILING_WHITESPACE | ||
) | ||
|
||
execute_process( | ||
COMMAND git log --pretty=format:%h -n 1 | ||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} | ||
OUTPUT_VARIABLE GIT_SHORT_COMMIT_HASH | ||
OUTPUT_STRIP_TRAILING_WHITESPACE | ||
) | ||
|
||
set(CPACK_SOURCE_PACKAGE_FILE_NAME | ||
${CMAKE_PROJECT_NAME}-${GIT_SHORT_COMMIT_HASH} | ||
) | ||
|
||
include(CPack) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
set(target_name | ||
pict_api_usage | ||
) | ||
|
||
set(pict_api_usage_output | ||
pictapisamples | ||
) | ||
|
||
set(pict_api_usage_src | ||
${CMAKE_CURRENT_SOURCE_DIR}/pictapi-sample.cpp | ||
) | ||
|
||
add_executable(${target_name} | ||
${pict_api_usage_src} | ||
) | ||
|
||
source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} | ||
FILES | ||
${pict_api_usage_src} | ||
) | ||
|
||
target_link_libraries(${target_name} | ||
PRIVATE | ||
PictBuildOptions | ||
pict_api | ||
) | ||
|
||
set_target_properties(${target_name} | ||
PROPERTIES | ||
FOLDER api-usage | ||
OUTPUT_NAME ${pict_api_usage_output} | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
set(target_name | ||
pict_api | ||
) | ||
|
||
set(pict_api_output | ||
pict | ||
) | ||
|
||
set(pict_api_inc | ||
${CMAKE_CURRENT_SOURCE_DIR}/deriver.h | ||
${CMAKE_CURRENT_SOURCE_DIR}/generator.h | ||
${CMAKE_CURRENT_SOURCE_DIR}/pictapi.h | ||
${CMAKE_CURRENT_SOURCE_DIR}/resource.h | ||
${CMAKE_CURRENT_SOURCE_DIR}/trie.h | ||
) | ||
|
||
set(pict_api_src | ||
${CMAKE_CURRENT_SOURCE_DIR}/combination.cpp | ||
${CMAKE_CURRENT_SOURCE_DIR}/deriver.cpp | ||
${CMAKE_CURRENT_SOURCE_DIR}/exclusion.cpp | ||
${CMAKE_CURRENT_SOURCE_DIR}/model.cpp | ||
${CMAKE_CURRENT_SOURCE_DIR}/parameter.cpp | ||
${CMAKE_CURRENT_SOURCE_DIR}/pictapi.cpp | ||
${CMAKE_CURRENT_SOURCE_DIR}/task.cpp | ||
${CMAKE_CURRENT_SOURCE_DIR}/worklist.cpp | ||
) | ||
|
||
add_library(${target_name} | ||
STATIC | ||
${pict_api_inc} | ||
${pict_api_src} | ||
) | ||
|
||
source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} | ||
FILES | ||
${pict_api_inc} | ||
${pict_api_src} | ||
) | ||
|
||
target_include_directories(${target_name} | ||
INTERFACE | ||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}> | ||
PRIVATE | ||
${CMAKE_CURRENT_SOURCE_DIR} | ||
) | ||
|
||
target_link_libraries(${target_name} | ||
PRIVATE | ||
PictBuildOptions | ||
) | ||
|
||
set_target_properties(${target_name} | ||
PROPERTIES | ||
FOLDER src | ||
OUTPUT_NAME ${pict_api_output} | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
include(GNUInstallDirs) | ||
|
||
set(target_name | ||
pict_cli | ||
) | ||
|
||
set(pict_cli_output | ||
pict | ||
) | ||
|
||
set(pict_cli_inc | ||
${CMAKE_CURRENT_SOURCE_DIR}/ccommon.h | ||
${CMAKE_CURRENT_SOURCE_DIR}/cmdline.h | ||
${CMAKE_CURRENT_SOURCE_DIR}/common.h | ||
${CMAKE_CURRENT_SOURCE_DIR}/cparser.h | ||
${CMAKE_CURRENT_SOURCE_DIR}/ctokenizer.h | ||
${CMAKE_CURRENT_SOURCE_DIR}/gcd.h | ||
${CMAKE_CURRENT_SOURCE_DIR}/gcdexcl.h | ||
${CMAKE_CURRENT_SOURCE_DIR}/gcdmodel.h | ||
${CMAKE_CURRENT_SOURCE_DIR}/model.h | ||
${CMAKE_CURRENT_SOURCE_DIR}/resource.h | ||
${CMAKE_CURRENT_SOURCE_DIR}/strings.h | ||
${CMAKE_CURRENT_SOURCE_DIR}/ver.h | ||
) | ||
|
||
set(pict_cli_src | ||
${CMAKE_CURRENT_SOURCE_DIR}/ccommon.cpp | ||
${CMAKE_CURRENT_SOURCE_DIR}/cmdline.cpp | ||
${CMAKE_CURRENT_SOURCE_DIR}/common.cpp | ||
${CMAKE_CURRENT_SOURCE_DIR}/cparser.cpp | ||
${CMAKE_CURRENT_SOURCE_DIR}/ctokenizer.cpp | ||
${CMAKE_CURRENT_SOURCE_DIR}/gcd.cpp | ||
${CMAKE_CURRENT_SOURCE_DIR}/gcdexcl.cpp | ||
${CMAKE_CURRENT_SOURCE_DIR}/gcdmodel.cpp | ||
${CMAKE_CURRENT_SOURCE_DIR}/model.cpp | ||
${CMAKE_CURRENT_SOURCE_DIR}/mparser.cpp | ||
${CMAKE_CURRENT_SOURCE_DIR}/pict.cpp | ||
${CMAKE_CURRENT_SOURCE_DIR}/strings.cpp | ||
) | ||
|
||
set(pict_cli_dll_src | ||
${pict_cli_src} PARENT_SCOPE | ||
) | ||
|
||
set(pict_cli_rc | ||
$<$<BOOL:${WIN32}>:${CMAKE_CURRENT_SOURCE_DIR}/Resource.rc> | ||
) | ||
|
||
add_executable(${target_name} | ||
${pict_cli_inc} | ||
${pict_cli_src} | ||
${pict_cli_rc} | ||
) | ||
|
||
source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} | ||
FILES | ||
${pict_cli_inc} | ||
${pict_cli_src} | ||
) | ||
|
||
target_link_libraries(${target_name} | ||
PRIVATE | ||
PictBuildOptions | ||
pict_api | ||
) | ||
|
||
set_target_properties(${target_name} | ||
PROPERTIES | ||
FOLDER src | ||
OUTPUT_NAME ${pict_cli_output} | ||
) | ||
|
||
install( | ||
PROGRAMS $<TARGET_FILE:${target_name}> | ||
TYPE BIN | ||
) | ||
|
||
install( | ||
FILES | ||
${CMAKE_SOURCE_DIR}/doc/pict.md | ||
${CMAKE_SOURCE_DIR}/LICENSE.TXT | ||
TYPE DOC | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
set(target_name | ||
pict_dll_usage | ||
) | ||
|
||
set(pict_dll_usage_output | ||
pictclidllusage | ||
) | ||
|
||
set(pict_dll_usage_src | ||
${CMAKE_CURRENT_SOURCE_DIR}/pictclidll-sample.cpp | ||
) | ||
|
||
add_executable(${target_name} | ||
${pict_dll_usage_src} | ||
) | ||
|
||
source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} | ||
FILES | ||
${pict_dll_usage_src} | ||
) | ||
|
||
target_link_libraries(${target_name} | ||
PRIVATE | ||
PictBuildOptions | ||
pict_dll | ||
) | ||
|
||
set_target_properties(${target_name} | ||
PROPERTIES | ||
FOLDER clidll-usage | ||
OUTPUT_NAME ${pict_dll_usage_output} | ||
) |
Oops, something went wrong.