xtd 0.2.0
Loading...
Searching...
No Matches
CMake commands

Contains specific CMake commands to manage project, assembly informations and application properties.

These specific CMake commands are automatically added when you add find_package(xtd REQUIRED) to your CMakeLists.txt file.

Examples
cmake_minimum_required(VERSION 3.20)
project(my_project)
find_package(xtd REQUIRED)
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition xtd_about_box.h:10
xtd Specific CMake commands
xtd Specific CMake variables

Generic commands

choice_options

Provides a choice options for the user to select an option from options list.

Parameters
OPTIONthe option to set.
MESSAGEDescription message for the choice options.
DEFAULT_OPTIONThe default option.
...Other options.
Remarks
This method must be call before target_type().
This method is optional.
Examples
cmake_minimum_required(VERSION 3.20)
project(my_project)
find_package(xtd REQUIRED)
add_sources(my_project.cpp)
choice_options(TARGET_TYPE "Choose library dynamic, static, interface or module" DYNAMIC_LIBRARY STATIC_LIBRARY INTERFACE_LIBRARY MODULE_LIBRARY)
target_type(${TARGET_TYPE})

Target properties commands

target_categories

Parameters
MAIN_CATEGORYMain categories to set.
ARGV0One or more additional categories to set.
Remarks
Only effect on linux.
If you don't specify the target_categories, the application has no category.
Call only once by project.
This method must be call before target_type().
This method is optional.
For more inforamtion see Desktop Entry Specification.
Examples
cmake_minimum_required(VERSION 3.20)
project(my_project)
find_package(xtd REQUIRED)
add_sources(my_project.cpp)
target_categories(Development IDE GUIDesigner)
target_type(CONSOLE_APPLICATION)

target_default_namespace

Specifies the the base namespace for files added to the project.

Parameters
TARGET_DEFAULT_NAMESPACEthe namespace to set.
Remarks
If you don't specify the target_default_namespace, it will be the same of the project name.
Call only once by project.
This method must be call before target_type().
This method is optional.
Examples
cmake_minimum_required(VERSION 3.20)
project(my_project)
find_package(xtd REQUIRED)
add_sources(my_project.cpp)
target_default_namespace("my_namespace")
target_type(CONSOLE_APPLICATION)

target_display

Specifies if application is displaying in GNOME or KDE menu.

Parameters
TARGET_DISPLAYoption to display (ON or OFF)
Remarks
Only effect on linux.
By default the application is registered but not visible in the general menu.
Call only once by project.
This method must be call before target_type().
This method is optional.
For more inforamtion see Desktop Entry Specification.
Examples
cmake_minimum_required(VERSION 3.20)
project(my_project)
find_package(xtd REQUIRED)
add_sources(my_project.cpp)
target_display(ON)
target_type(GUI_APPLICATION)

target_icon

Specifies the icon file (.ico for Windows, icons for maOS and png or svg for linux) that you want to use as your program icon.

Parameters
ARGV0the icon to set without extension. It can be empty.
Remarks
Do not specify the extension of file. It's operation system dependant.
If you write multiplatform application you must have the specified file in ico, icons and png or svg formats.
On Linux you can specify one icon format like icon.png or icon.svg (typically 512 x 512 pixels) or more icon format terminated by the number of pixels:
  • icon8.png (8 x 8 pixels)
  • icon16.png (16 x 16 pixels)
  • icon22.png (22 x 22 pixels)
  • icon24.png (24 x 24 pixels)
  • icon32.png (32 x 32 pixels)
  • icon36.png (36 x 36 pixels)
  • icon42.png (42 x 42 pixels)
  • icon48.png (48 x 48 pixels)
  • icon52.png (52 x 52 pixels)
  • icon64.png (64 x 64 pixels)
  • icon72.png (72 x 72 pixels)
  • icon96.png (96 x 96 pixels)
  • icon128.png (128 x 128 pixels)
  • icon192.png (192 x 192 pixels)
  • icon256.png (256 x 256 pixels)
  • icon512.png (512 x 512 pixels)
Call only once by project.
This method must be call before target_type().
This method is optional.
Examples
cmake_minimum_required(VERSION 3.20)
project(my_project)
find_package(xtd REQUIRED)
add_sources(my_project.cpp)
target_icon(my_icon)
target_type(CONSOLE_APPLICATION)

target_name

Specifies the name of the output file.

Parameters
TARGET_NAMEthe name to set.
Remarks
If you don't specify the target_name, it will be the same of the project name.
Call only once by project.
This method must be call before target_type().
This method is optional.
Examples
cmake_minimum_required(VERSION 3.20)
project(my_project)
find_package(xtd REQUIRED)
add_sources(my_project.cpp)
target_name("my_exe")
target_type(CONSOLE_APPLICATION)

target_registered

Specify the application is registered in the system.

Remarks
Only effect on linux.
By default the application is registered but not visible in GNOME or KDE menu.
Call only once by project.
This method must be call before target_type().
This method is optional.
Examples
cmake_minimum_required(VERSION 3.20)
project(my_project)
find_package(xtd REQUIRED)
add_sources(my_project.cpp)
target_registered(OFF)
target_type(GUI_APPLICATION)

target_startup

Specifies the entry point to be called when the application is load.

Parameters
ARGV0the object that contains the entry point.
ARGV1the object definition file. (optional if you use TUnitMain_ or TUnitFrameworkMain_ entry point)
Remarks
Do not use this method of startup_(...) is present in your files or if you use standard c++ main() method.
Call only once by project.
This method must be call before target_type().
This method is optional.
Examples
cmake_minimum_required(VERSION 3.20)
project(my_project)
find_package(xtd REQUIRED)
add_sources(my_project.cpp)
target_startup("my_project::my_class" my_project.cpp)
target_type(GUI_APPLICATION)

target_type

Specifies the type of application to build.

Parameters
TARGET_TYPEType of application. Possible values :
  • CONSOLE_APPLICATION Console application
  • GUI_APPLICATION Gui application (Winforms)
  • TEST_APPLICATION Test application (TUnit)
  • MODULE_LIBRARY Module library
  • SHARED_LIBRARY Shared library (.dll or .so)
  • STATIC_LIBRARY Static library (.lib or .a)
  • INTERFACE_LIBRARY Interface library (header files only)
  • CUSTOM_TARGET Target with no output.
Remarks
This method is required except container project like Solution.
This method must be the last method.
Call only once by project.
Examples
cmake_minimum_required(VERSION 3.20)
project(my_project)
find_package(xtd REQUIRED)
add_sources(my_project.cpp)
add_references(xtd.drawing xtd.drawing.native)
target_type(CONSOLE_APPLICATION)

Assembly informations commands

assembly_company

Specifies a company name for the assembly manifest. Corresponds to AssemblyCompanyAttribute.

Parameters
ASSEMBLY_COMPANYThe company name to set.
Remarks
Call only once by project.
This method must be call before target_type().
This method is optional.
Examples
cmake_minimum_required(VERSION 3.20)
project(my_project)
find_package(xtd REQUIRED)
add_sources(my_project.cpp)
assembly_company("Gammasoft")
target_type(GUI_APPLICATION)

assembly_configuration

Specifies a configuration for the assembly manifest. Corresponds to AssemblyConfigurationAttribute.

Parameters
ASSEMBLY_CONFIGURATIONThe configuration to set.
Remarks
Call only once by project.
This method must be call before target_type().
This method is optional.
Examples
cmake_minimum_required(VERSION 3.20)
project(my_project)
find_package(xtd REQUIRED)
add_sources(my_project.cpp)
assembly_configuration("Beta public")
target_type(GUI_APPLICATION)

assembly_copyright

Specifies a copyright notice for the assembly manifest. Corresponds to AssemblyCopyrightAttribute.

Parameters
ASSEMBLY_COPYRIGHTThe copyright to set.
Remarks
Call only once by project.
This method must be call before target_type().
This method is optional.
Examples
cmake_minimum_required(VERSION 3.20)
project(my_project)
find_package(xtd REQUIRED)
add_sources(my_project.cpp)
assembly_copyright("© 2024 by Gammasoft.")
target_type(GUI_APPLICATION)

assembly_culture

Specifies the culture for the assembly manifest. Corresponds to AssemblyConfigurationAttribute.

Parameters
ASSEMBLY_CONFIGURATIONThe culture to set.
Remarks
Call only once by project.
This method must be call before target_type().
This method is optional.

assembly_description

Specifies an optional description for the assembly manifest. Corresponds to AssemblyDescriptionAttribute.

Parameters
ASSEMBLY_DESCRIPTIONThe description to set.
Remarks
Call only once by project.
This method must be call before target_type().
This method is optional.
Examples
cmake_minimum_required(VERSION 3.20)
project(my_project)
find_package(xtd REQUIRED)
add_sources(my_project.cpp)
assembly_description("The application to stuff it.")
target_type(GUI_APPLICATION)

assembly_file_version

Specifies a version number that instructs the compiler to use a specific version for the Win32 file version resource. Corresponds to AssemblyFileVersionAttribute.

Parameters
ASSEMBLY_FILE_VERSIONThe file version to set (Major, Minor and build).
Remarks
Call only once by project.
This method must be call before target_type().
This method is optional.
Examples
cmake_minimum_required(VERSION 3.20)
project(my_project)
find_package(xtd REQUIRED)
add_sources(my_project.cpp)
assembly_file_version("1.2.3")
target_type(GUI_APPLICATION)

assembly_guid

Specifies an unique GUID that identifies the assembly. When you create a project, Visual Studio generates a GUID for the assembly. Corresponds to Guid.

Parameters
ASSEMBLY_GUIDThe guid to set.
Remarks
Call only once by project.
This method must be call before target_type().
This method is optional.
Examples
cmake_minimum_required(VERSION 3.20)
project(my_project)
find_package(xtd REQUIRED)
add_sources(my_project.cpp)
assembly_guid("fc5beb89-a4cc-445e-8ef7-07a9e471ef9a")
target_type(GUI_APPLICATION)

assembly_product

Specifies a product name for the assembly manifest. Corresponds to AssemblyProductAttribute.

Parameters
ASSEMBLY_PRODUCTThe product name to set.
Remarks
Call only once by project.
This method must be call before target_type().
This method is optional.
Examples
cmake_minimum_required(VERSION 3.20)
project(my_project)
find_package(xtd REQUIRED)
add_sources(my_project.cpp)
assembly_product("my_project")
target_type(GUI_APPLICATION)

assembly_title

Specifies a title for the assembly manifest. Corresponds to AssemblyTitleAttribute.

Parameters
ASSEMBLY_TITLEThe title to set.
Remarks
Call only once by project.
This method must be call before target_type().
This method is optional.
Examples
cmake_minimum_required(VERSION 3.20)
project(my_project)
find_package(xtd REQUIRED)
add_sources(my_project.cpp)
assembly_title("My Project")
target_type(GUI_APPLICATION)

assembly_trademark

Specifies a trademark for the assembly manifest. Corresponds to AssemblyTrademarkAttribute.

Parameters
ASSEMBLY_TRADEMARKThe trademark to set.
Remarks
Call only once by project.
This method must be call before target_type().
This method is optional.

assembly_version

Specifies the version of the assembly. Corresponds to AssemblyVersionAttribute.

Parameters
ASSEMBLY_FILE_VERSIONThe version to set (Major, Minor and build).
Remarks
Call only once by project.
This method must be call before target_type().
This method is optional.
Examples
cmake_minimum_required(VERSION 3.20)
project(my_project)
find_package(xtd REQUIRED)
add_sources(my_project.cpp)
assembly_version("1.2.3")
target_type(GUI_APPLICATION)

Build options commands

build_output_directory

Specifies the directory into which runtime target files should be built.

Parameters
OUTPUT_DIRECTORYthe directory where runtime target files should be built.
Remarks
This option is use mainly when a solution as more than one project.
Examples
cmake_minimum_required(VERSION 3.20)
project(MySolution)
find_package(xtd REQUIRED)
build_output_directory("${USER_DIRECTORY}/Output")
add_projects(lib_project1 lib_project2 lib_project3)
add_projects(tests/test_lib_project1 tests/test_lib_project2 tests/test_lib_project3)

Install commands

add_install_include_directories

Installs include directories.

Parameters
ARGNInclude directories to install.
Remarks
This method is required for install package.
This method can be call more than once in the same project.
Examples
cmake_minimum_required(VERSION 3.20)
project(my_project)
find_package(xtd REQUIRED)
add_sources(src/my_project1.cpp src/my_project2.cpp include/my_project/my_project.h include/my_project/MyProject2.h)
target_type(STATIC_LIBRARY)
add_install_include_directories(include/my_project)
install_component()
install_application()

add_install_include_files

Installs include files.

Parameters
ARGNInclude files to install.
Remarks
This method is required for install package.
This method can be call more than once in the same project.
Examples
cmake_minimum_required(VERSION 3.20)
project(my_project)
find_package(xtd REQUIRED)
add_sources(my_project1.cpp my_project2.cpp my_project.h MyProject2.h)
target_type(STATIC_LIBRARY)
install_include_files(my_project1.h my_project2.h)
install_component()
install_application()

install_component

Parameters
ARGV0Install name (optional).
Remarks
if install name no specified and install_name() method no called, the install name is equal to application name.
This method is required for install package.
This method must be call after target_type.
Call only once by project.
Examples
cmake_minimum_required(VERSION 3.20)
project(my_project)
find_package(xtd REQUIRED)
add_sources(my_project.cpp my_project.h)
target_type(STATIC_LIBRARY)
add_install_include_files(my_project.h)
install_component()
install_package()

install_package

Installs package MODULE_LIBRARY, STATIC_LIBRARY or SHARED_LIBRARY package.

Parameters
ARGV0Install name (optional).
Remarks
if install name no specified and install_name() method no called, the install name is equal to application name.
This method is required for install package.
This method must be after target_type.
Call only once by project.
Examples
cmake_minimum_required(VERSION 3.20)
project(my_project)
find_package(xtd REQUIRED)
add_sources(my_project.cpp my_project.h)
target_type(STATIC_LIBRARY)
add_install_include_files(my_project.h)
install_component()
install_package()

install_name

Specifies the install name.

Parameters
NAMEInstall name.
Remarks
This method is optional.
This method must be after add_references.
Call only once by project.
Examples
cmake_minimum_required(VERSION 3.20)
project(my_project)
find_package(xtd REQUIRED)
add_sources(my_project.cpp my_project.h)
target_type(STATIC_LIBRARY)
install_name("specific_project")
add_install_include_files(my_project.h)
install_component()
install_application()

Project commands

add_include_directories

Add include directory to current project.

Parameters
ARGNdirectories to add.
Remarks
This method can be call more than once in the same project.
This method must be call before target_type().
This method is optional.
Examples
cmake_minimum_required(VERSION 3.20)
project(my_project)
find_package(xtd REQUIRED)
add_include_directories(include)
add_sources(my_project.cpp include/my_project/my_project.h)
target_type(STATIC_LIBRARY)

add_packages

Adds, finds and loads settings from external required projects to current project.

Parameters
ARGNpackages to add.
Remarks
This method can be call more than once in the same project.
This method must be call before target_type().
This method is optional.
Examples
cmake_minimum_required(VERSION 3.20)
project(my_project)
find_package(xtd REQUIRED)
add_packages(my_package1 my_package2)
add_references(my_project1_in_my_package1 my_project1_in_my_package2 my_project2_in_my_package2)
add_sources(my_project.cpp)
target_type(CONSOLE_APPLICATION)

add_projects

Add child projects to parent project.

Parameters
ARGNprojects to add.
Remarks
The path can be relative from CMAKE_CURRENT_SOURCE_DIR or absolute.
This method can be call more than once in the same project.
This method is optional except container project like Solution.
This method must be call before target_type().
Examples
cmake_minimum_required(VERSION 3.20)
project(MySolution)
find_package(xtd REQUIRED)
add_projects(lib_project1 lib_project2 lib_project3)
add_projects(tests/test_lib_project1 tests/test_lib_project2 tests/test_lib_project3)

add_references

Add references (libraries) to current project.

Parameters
ARGNreferences to add.
Remarks
This method must be call before target_type().
This method is optional.
Examples
cmake_minimum_required(VERSION 3.20)
project(my_project)
find_package(xtd REQUIRED)
add_sources(my_project.cpp)
add_references(xtd.drawing xtd.drawing.native)
add_references(xtd.forms)
target_type(CONSOLE_APPLICATION)
The xtd::forms namespace contains classes for creating Windows-based applications that take full adva...
Definition xtd_about_box.h:12

resource

Add resources to current project.

Parameters
NAMEresource name to add.
FILEresource file to add.
Remarks
The path can be relative from CMAKE_CURRENT_SOURCE_DIR or absolute.
This method can be call more than once in the same project.
This method must be call before target_type().
This method is optional.
Examples
cmake_minimum_required(VERSION 3.20)
project(my_project)
find_package(xtd REQUIRED)
add_sources(file.h file.cpp)
resource(image1 resources/image1.png)
resource(image2 resources/image2.bmp)
resource(animation1 animations/ani1.gif)
target_type(CONSOLE_APPLICATION)

resource_string

Add resource string to current project.

Parameters
NAMEName of string to add.
VALUEValue of string to add.
COMMENTComment of string to add.
Remarks
This method can be call more than once in the same project.
This method must be call before target_type().
This method is optional.
Examples
cmake_minimum_required(VERSION 3.20)
project(my_project)
find_package(xtd REQUIRED)
add_sources(file.h file.cpp)
resource_string(caption "\"Form examples\"" "Caption of main Form.")
resource_string(button_close_text "\"Close\"" "Text of close button.")
target_type(GUI_APPLICATION)

setting

Add a setting to current project.

Parameters
NAMEThe name of setting to add.
TYPEThe type of setting to add.
SCOPEThe scope of setting to add (APPLICATION or USER).
VALUEThe value of setting to add.
Remarks
Application-scope settings are read only at run time.
User-scope settings are read/write at run time, and their values can be changed and saved in code.
This method can be call more than once in the same project.
This method must be call before target_type().
This method is optional.
Examples
cmake_minimum_required(VERSION 3.20)
project(my_project)
find_package(xtd REQUIRED)
add_sources(file.h file.cpp)
setting(name xtd::string APPLICATION "\"Settings example\"")
setting(back_color xtd::drawing::color USER "xtd::drawing::color::spring_green")
target_type(CONSOLE_APPLICATION)

setting_include

Adds a setting include file to current project.

Parameters
SETTIING_INCLUDE_FILEThe include file to add.
Remarks
This method can be call more than once in the same project.
This method must be call before target_type().
This method is optional.
Examples
cmake_minimum_required(VERSION 3.20)
project(my_project)
find_package(xtd REQUIRED)
add_sources(file.h file.cpp)
setting_include("xtd/drawing/color")
setting_include("xtd/string")
setting(name xtd::string APPLICATION "\"Settings example\"")
setting(back_color xtd::drawing::color USER "xtd::drawing::color::spring_green")
target_type(CONSOLE_APPLICATION)

add_sources

Add source and header files to current project.

Parameters
ARGNFiles list to add.
Remarks
The path can be relative from CMAKE_CURRENT_SOURCE_DIR or absolute.
This method can be call more than once in the same project.
This method is required except container project like Solution.
This method must be call before target_type().
Examples
cmake_minimum_required(VERSION 3.20)
project(my_project)
find_package(xtd REQUIRED)
add_sources(file1.h file2.h options/file3.h)
add_sources(file1.cpp file2.cpp options/file3.cpp)
target_type(CONSOLE_APPLICATION)

Target properties Variables

TARGET_CATEGORIES

Contains the application categories.

See also
target_categories

TARGET_DEFAULT_NAMESPACE

Contains default namespace use by application.

See also
target_default_namespace

TARGET_ICON

Contains application icon file name without extension.

See also
target_icon

TARGET_NAME

Contains application name.

See also
target_name

TARGET_REGISTERED

Contains boolean that specify if application is registered or not on the system.

TARGET_TYPE

Contains application type.

See also
target_type

Assembly informations Variables

ASSEMBLY_COMPANY

Contains assembly company name.

See also
assembly_company

ASSEMBLY_CONFIGURATION

Contains assembly configuration string.

See also
assembly_configuration

ASSEMBLY_COPYRIGHT

Contains assembly copyright string.

See also
assembly_copyright

ASSEMBLY_CULTURE

Contains assembly culture information.

See also
assembly_culture

ASSEMBLY_DESCRIPTION

Contains assembly description string.

See also
assembly_description

ASSEMBLY_FILE_VERSION

Contains assembly file version number.

See also
assembly_file_version

ASSEMBLY_GUID

Contains assembly guid string.

See also
assembly_guid

ASSEMBLY_PRODUCT

Contains assembly product string.

See also
assembly_product

ASSEMBLY_TITLE

Contains assembly title string.

See also
assembly_title

ASSEMBLY_TRADEMARK

Contains assembly trademark information.

See also
assembly_trademark

ASSEMBLY_VERSION

Contains assembly version number.

See also
assembly_version

Build options Variables

BUILD_OUTPUT_DIRECTORY

Contains build output directory.

See also
build_output_directory

BUILD_TYPE

Contains build type.

Install Variables

INSTALL_COMPONENTS

Contains install project components.

See also
install_component

INSTALL_INCLUDE_DIRECTORIES

Contains install include directories.

See also
add_install_include_directories

INSTALL_INCLUDE_FILES

Contains install include files.

See also
add_install_include_files

INSTALL_NAME

Contains install name.

See also
install_name

Project Variables

PROJECT_APPLICATION_SETTINGS

Contains project application settings.

See also
setting

PROJECT_INCLUDE_DIRECTORIES

Contains include directories.

See also
add_include_directories

PROJECT_PACKAGES

Contains project packages.

See also
add_packages

PROJECT_PROJECTS

Contains solution or project projects.

See also
add_projects

PROJECT_REFERENCES

Contains project references.

See also
add_references

PROJECT_RESOURCES

Contains project resources.

See also
resource

PROJECT_RESOURCE_STRINGS

Contains project resource strings.

See also
resource_string

PROJECT_SETTING_INCLUDE_FILES

Contains project setting include files.

See also
setting_include

PROJECT_SOURCES

Contains project sources.

See also
add_sources

PROJECT_USER_SETTINGS

Contains project user settings.

See also
setting

System Variables

USER_DIRECTORY

The path to user home.