C Make Lists
C Make Lists
C Make Lists
cmake_minimum_required(VERSION 3.15)
set(CMKR_ROOT_PROJECT OFF)
if(CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
set(CMKR_ROOT_PROJECT ON)
# Options
option(ZASM_BUILD_TESTS "" OFF)
option(ZASM_BUILD_BENCHMARKS "" OFF)
option(ZASM_BUILD_EXAMPLES "" OFF)
project(zasm
LANGUAGES
CXX
)
# Subdirectory: thirdparty
set(CMKR_CMAKE_FOLDER ${CMAKE_FOLDER})
if(CMAKE_FOLDER)
set(CMAKE_FOLDER "${CMAKE_FOLDER}/thirdparty")
else()
set(CMAKE_FOLDER thirdparty)
endif()
add_subdirectory(thirdparty)
set(CMAKE_FOLDER ${CMKR_CMAKE_FOLDER})
# Target: zasm_common
add_library(zasm_common INTERFACE)
# Target: zasm
set(zasm_SOURCES
"src/zasm/src/core/filestream.cpp"
"src/zasm/src/core/memorystream.cpp"
"src/zasm/src/decoder/decoder.cpp"
"src/zasm/src/encoder/encoder.cpp"
"src/zasm/src/formatter/formatter.cpp"
"src/zasm/src/program/data.cpp"
"src/zasm/src/program/instruction.cpp"
"src/zasm/src/program/program.cpp"
"src/zasm/src/program/register.cpp"
"src/zasm/src/program/saverestore.cpp"
"src/zasm/src/program/saverestore.load.cpp"
"src/zasm/src/program/saverestore.save.cpp"
"src/zasm/src/serialization/serializer.cpp"
"src/zasm/src/x86/x86.assembler.cpp"
"src/zasm/src/x86/x86.register.cpp"
"src/zasm/src/zasm.cpp"
"src/zasm/src/encoder/encoder.context.hpp"
"src/zasm/src/program/program.node.hpp"
"src/zasm/src/program/program.state.hpp"
"src/zasm/src/program/saverestorehelper.hpp"
"src/zasm/src/program/saverestoretypes.hpp"
"include/zasm/base/immediate.hpp"
"include/zasm/base/instruction.hpp"
"include/zasm/base/label.hpp"
"include/zasm/base/memory.hpp"
"include/zasm/base/meta.hpp"
"include/zasm/base/mode.hpp"
"include/zasm/base/operand.hpp"
"include/zasm/base/register.hpp"
"include/zasm/core/bitsize.hpp"
"include/zasm/core/enumflags.hpp"
"include/zasm/core/errors.hpp"
"include/zasm/core/expected.hpp"
"include/zasm/core/filestream.hpp"
"include/zasm/core/math.hpp"
"include/zasm/core/memorystream.hpp"
"include/zasm/core/objectpool.hpp"
"include/zasm/core/packed.hpp"
"include/zasm/core/stream.hpp"
"include/zasm/core/stringpool.hpp"
"include/zasm/core/strongtype.hpp"
"include/zasm/decoder/decoder.hpp"
"include/zasm/encoder/encoder.hpp"
"include/zasm/formatter/formatter.hpp"
"include/zasm/program/align.hpp"
"include/zasm/program/data.hpp"
"include/zasm/program/embeddedlabel.hpp"
"include/zasm/program/instruction.hpp"
"include/zasm/program/labeldata.hpp"
"include/zasm/program/node.hpp"
"include/zasm/program/observer.hpp"
"include/zasm/program/program.hpp"
"include/zasm/program/saverestore.hpp"
"include/zasm/program/section.hpp"
"include/zasm/program/sentinel.hpp"
"include/zasm/serialization/serializer.hpp"
"include/zasm/x86/assembler.hpp"
"include/zasm/x86/emitter.hpp"
"include/zasm/x86/memory.hpp"
"include/zasm/x86/meta.hpp"
"include/zasm/x86/mnemonic.hpp"
"include/zasm/x86/register.hpp"
"include/zasm/x86/x86.hpp"
"include/zasm/zasm.hpp"
cmake.toml
)
add_library(zasm STATIC)
target_link_libraries(zasm PUBLIC
zasm::common
Zydis
)
# Target: zasm_testdata
if(ZASM_BUILD_TESTS OR CMKR_ROOT_PROJECT) # tests
add_library(zasm_testdata INTERFACE)
endif()
# Target: zasm_tests
if(ZASM_BUILD_TESTS OR CMKR_ROOT_PROJECT) # tests
set(zasm_tests_SOURCES
"src/tests/main.cpp"
"src/tests/tests/tests.assembler.cpp"
"src/tests/tests/tests.decoder.cpp"
"src/tests/tests/tests.externals.cpp"
"src/tests/tests/tests.formatter.cpp"
"src/tests/tests/tests.imports.cpp"
"src/tests/tests/tests.instruction.cpp"
"src/tests/tests/tests.instructions.x64.cpp"
"src/tests/tests/tests.instructionsinfo.x64.cpp"
"src/tests/tests/tests.observer.cpp"
"src/tests/tests/tests.packed.cpp"
"src/tests/tests/tests.program.cpp"
"src/tests/tests/tests.registers.cpp"
"src/tests/tests/tests.relocation.cpp"
"src/tests/tests/tests.saverestore.cpp"
"src/tests/tests/tests.sections.cpp"
"src/tests/tests/tests.segments.cpp"
"src/tests/tests/tests.serialization.cpp"
"src/tests/tests/tests.stringpool.cpp"
"src/tests/testutils.cpp"
"src/tests/testutils.hpp"
cmake.toml
)
add_executable(zasm_tests)
target_link_libraries(zasm_tests PRIVATE
zasm::common
zasm::zasm
zasm::testdata
GTest::gtest
)
set_target_properties(zasm_tests PROPERTIES
PROJECT_LABEL
tests
)
get_directory_property(CMKR_VS_STARTUP_PROJECT DIRECTORY $
{PROJECT_SOURCE_DIR} DEFINITION VS_STARTUP_PROJECT)
if(NOT CMKR_VS_STARTUP_PROJECT)
set_property(DIRECTORY ${PROJECT_SOURCE_DIR} PROPERTY
VS_STARTUP_PROJECT zasm_tests)
endif()
endif()
# Target: zasm_benchmarks
if(ZASM_BUILD_TESTS OR CMKR_ROOT_PROJECT) # tests
set(zasm_benchmarks_SOURCES
"src/benchmark/benchmarks/benchmark.assembler.cpp"
"src/benchmark/benchmarks/benchmark.formatter.cpp"
"src/benchmark/benchmarks/benchmark.instructioninfo.cpp"
"src/benchmark/benchmarks/benchmark.serialization.cpp"
"src/benchmark/benchmarks/benchmark.stringpool.cpp"
"src/benchmark/main.cpp"
cmake.toml
)
add_executable(zasm_benchmarks)
target_link_libraries(zasm_benchmarks PRIVATE
zasm::common
zasm::zasm
zasm::testdata
benchmark::benchmark
)
set_target_properties(zasm_benchmarks PROPERTIES
PROJECT_LABEL
benchmarks
)
get_directory_property(CMKR_VS_STARTUP_PROJECT DIRECTORY $
{PROJECT_SOURCE_DIR} DEFINITION VS_STARTUP_PROJECT)
if(NOT CMKR_VS_STARTUP_PROJECT)
set_property(DIRECTORY ${PROJECT_SOURCE_DIR} PROPERTY
VS_STARTUP_PROJECT zasm_benchmarks)
endif()
endif()
# Target: zasm_example_common
if(ZASM_BUILD_EXAMPLES OR CMKR_ROOT_PROJECT) # examples
add_library(zasm_example_common INTERFACE)
target_link_libraries(zasm_example_common INTERFACE
zasm::common
zasm::zasm
)
endif()
# Target: zasm_example_assembler_basic
if(ZASM_BUILD_EXAMPLES OR CMKR_ROOT_PROJECT) # examples
set(zasm_example_assembler_basic_SOURCES
"examples/assembler_basic/main.cpp"
cmake.toml
)
add_executable(zasm_example_assembler_basic)
target_sources(zasm_example_assembler_basic PRIVATE $
{zasm_example_assembler_basic_SOURCES})
source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES $
{zasm_example_assembler_basic_SOURCES})
target_link_libraries(zasm_example_assembler_basic PRIVATE
zasm::examples::common
)
set_target_properties(zasm_example_assembler_basic PROPERTIES
FOLDER
examples
PROJECT_LABEL
assembler_basic
RUNTIME_OUTPUT_NAME
example.assembler_basic
)
get_directory_property(CMKR_VS_STARTUP_PROJECT DIRECTORY $
{PROJECT_SOURCE_DIR} DEFINITION VS_STARTUP_PROJECT)
if(NOT CMKR_VS_STARTUP_PROJECT)
set_property(DIRECTORY ${PROJECT_SOURCE_DIR} PROPERTY
VS_STARTUP_PROJECT zasm_example_assembler_basic)
endif()
endif()
# Target: zasm_example_assembler_sections
if(ZASM_BUILD_EXAMPLES OR CMKR_ROOT_PROJECT) # examples
set(zasm_example_assembler_sections_SOURCES
"examples/assembler_sections/main.cpp"
cmake.toml
)
add_executable(zasm_example_assembler_sections)
target_sources(zasm_example_assembler_sections PRIVATE $
{zasm_example_assembler_sections_SOURCES})
source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES $
{zasm_example_assembler_sections_SOURCES})
target_link_libraries(zasm_example_assembler_sections PRIVATE
zasm::examples::common
)
set_target_properties(zasm_example_assembler_sections PROPERTIES
FOLDER
examples
PROJECT_LABEL
assembler_sections
RUNTIME_OUTPUT_NAME
example.assembler_sections
)
get_directory_property(CMKR_VS_STARTUP_PROJECT DIRECTORY $
{PROJECT_SOURCE_DIR} DEFINITION VS_STARTUP_PROJECT)
if(NOT CMKR_VS_STARTUP_PROJECT)
set_property(DIRECTORY ${PROJECT_SOURCE_DIR} PROPERTY
VS_STARTUP_PROJECT zasm_example_assembler_sections)
endif()
endif()
# Target: zasm_example_decode_to_assembler
if(ZASM_BUILD_EXAMPLES OR CMKR_ROOT_PROJECT) # examples
set(zasm_example_decode_to_assembler_SOURCES
"examples/decode_to_assembler/main.cpp"
cmake.toml
)
add_executable(zasm_example_decode_to_assembler)
target_sources(zasm_example_decode_to_assembler PRIVATE $
{zasm_example_decode_to_assembler_SOURCES})
source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES $
{zasm_example_decode_to_assembler_SOURCES})
target_link_libraries(zasm_example_decode_to_assembler PRIVATE
zasm::examples::common
)
set_target_properties(zasm_example_decode_to_assembler PROPERTIES
FOLDER
examples
PROJECT_LABEL
decode_to_assembler
RUNTIME_OUTPUT_NAME
example.decode_to_assembler
)
get_directory_property(CMKR_VS_STARTUP_PROJECT DIRECTORY $
{PROJECT_SOURCE_DIR} DEFINITION VS_STARTUP_PROJECT)
if(NOT CMKR_VS_STARTUP_PROJECT)
set_property(DIRECTORY ${PROJECT_SOURCE_DIR} PROPERTY
VS_STARTUP_PROJECT zasm_example_decode_to_assembler)
endif()
endif()
# Target: zasm_example_program_observer
if(ZASM_BUILD_EXAMPLES OR CMKR_ROOT_PROJECT) # examples
set(zasm_example_program_observer_SOURCES
"examples/program_observer/main.cpp"
cmake.toml
)
add_executable(zasm_example_program_observer)
target_sources(zasm_example_program_observer PRIVATE $
{zasm_example_program_observer_SOURCES})
source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES $
{zasm_example_program_observer_SOURCES})
target_link_libraries(zasm_example_program_observer PRIVATE
zasm::examples::common
)
set_target_properties(zasm_example_program_observer PROPERTIES
FOLDER
examples
PROJECT_LABEL
program_observer
RUNTIME_OUTPUT_NAME
example.program_observer
)
get_directory_property(CMKR_VS_STARTUP_PROJECT DIRECTORY $
{PROJECT_SOURCE_DIR} DEFINITION VS_STARTUP_PROJECT)
if(NOT CMKR_VS_STARTUP_PROJECT)
set_property(DIRECTORY ${PROJECT_SOURCE_DIR} PROPERTY
VS_STARTUP_PROJECT zasm_example_program_observer)
endif()
endif()
# Target: zasm_example_instruction_info
if(ZASM_BUILD_EXAMPLES OR CMKR_ROOT_PROJECT) # examples
set(zasm_example_instruction_info_SOURCES
"examples/instruction_info/main.cpp"
cmake.toml
)
add_executable(zasm_example_instruction_info)
target_sources(zasm_example_instruction_info PRIVATE $
{zasm_example_instruction_info_SOURCES})
source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES $
{zasm_example_instruction_info_SOURCES})
target_link_libraries(zasm_example_instruction_info PRIVATE
zasm::examples::common
)
set_target_properties(zasm_example_instruction_info PROPERTIES
FOLDER
examples
PROJECT_LABEL
instruction_info
RUNTIME_OUTPUT_NAME
example.instruction_info
)
get_directory_property(CMKR_VS_STARTUP_PROJECT DIRECTORY $
{PROJECT_SOURCE_DIR} DEFINITION VS_STARTUP_PROJECT)
if(NOT CMKR_VS_STARTUP_PROJECT)
set_property(DIRECTORY ${PROJECT_SOURCE_DIR} PROPERTY
VS_STARTUP_PROJECT zasm_example_instruction_info)
endif()
endif()
# Target: zasm_example_modify_program
if(ZASM_BUILD_EXAMPLES OR CMKR_ROOT_PROJECT) # examples
set(zasm_example_modify_program_SOURCES
"examples/modify_program/main.cpp"
cmake.toml
)
add_executable(zasm_example_modify_program)
target_sources(zasm_example_modify_program PRIVATE $
{zasm_example_modify_program_SOURCES})
source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES $
{zasm_example_modify_program_SOURCES})
target_link_libraries(zasm_example_modify_program PRIVATE
zasm::examples::common
)
set_target_properties(zasm_example_modify_program PROPERTIES
FOLDER
examples
PROJECT_LABEL
modify_program
RUNTIME_OUTPUT_NAME
example.modify_program
)
get_directory_property(CMKR_VS_STARTUP_PROJECT DIRECTORY $
{PROJECT_SOURCE_DIR} DEFINITION VS_STARTUP_PROJECT)
if(NOT CMKR_VS_STARTUP_PROJECT)
set_property(DIRECTORY ${PROJECT_SOURCE_DIR} PROPERTY
VS_STARTUP_PROJECT zasm_example_modify_program)
endif()
endif()
# Target: zasm_example_basic_jit
if(ZASM_BUILD_EXAMPLES OR CMKR_ROOT_PROJECT) # examples
set(zasm_example_basic_jit_SOURCES
"examples/basic_jit/main.cpp"
cmake.toml
)
add_executable(zasm_example_basic_jit)
target_sources(zasm_example_basic_jit PRIVATE $
{zasm_example_basic_jit_SOURCES})
source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES $
{zasm_example_basic_jit_SOURCES})
target_link_libraries(zasm_example_basic_jit PRIVATE
zasm::examples::common
)
set_target_properties(zasm_example_basic_jit PROPERTIES
FOLDER
examples
PROJECT_LABEL
basic_jit
RUNTIME_OUTPUT_NAME
example.basic_jit
)
get_directory_property(CMKR_VS_STARTUP_PROJECT DIRECTORY $
{PROJECT_SOURCE_DIR} DEFINITION VS_STARTUP_PROJECT)
if(NOT CMKR_VS_STARTUP_PROJECT)
set_property(DIRECTORY ${PROJECT_SOURCE_DIR} PROPERTY
VS_STARTUP_PROJECT zasm_example_basic_jit)
endif()
endif()
# Target: zasm_example_modify_instruction
if(ZASM_BUILD_EXAMPLES OR CMKR_ROOT_PROJECT) # examples
set(zasm_example_modify_instruction_SOURCES
"examples/modify_instruction/main.cpp"
cmake.toml
)
add_executable(zasm_example_modify_instruction)
target_sources(zasm_example_modify_instruction PRIVATE $
{zasm_example_modify_instruction_SOURCES})
source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES $
{zasm_example_modify_instruction_SOURCES})
target_link_libraries(zasm_example_modify_instruction PRIVATE
zasm::examples::common
)
set_target_properties(zasm_example_modify_instruction PROPERTIES
FOLDER
examples
PROJECT_LABEL
modify_instruction
RUNTIME_OUTPUT_NAME
example.modify_instruction
)
get_directory_property(CMKR_VS_STARTUP_PROJECT DIRECTORY $
{PROJECT_SOURCE_DIR} DEFINITION VS_STARTUP_PROJECT)
if(NOT CMKR_VS_STARTUP_PROJECT)
set_property(DIRECTORY ${PROJECT_SOURCE_DIR} PROPERTY
VS_STARTUP_PROJECT zasm_example_modify_instruction)
endif()
endif()
# Target: zasm_example_memory_operands
if(ZASM_BUILD_EXAMPLES OR CMKR_ROOT_PROJECT) # examples
set(zasm_example_memory_operands_SOURCES
"examples/memory_operands/main.cpp"
cmake.toml
)
add_executable(zasm_example_memory_operands)
target_sources(zasm_example_memory_operands PRIVATE $
{zasm_example_memory_operands_SOURCES})
source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES $
{zasm_example_memory_operands_SOURCES})
target_link_libraries(zasm_example_memory_operands PRIVATE
zasm::examples::common
)
set_target_properties(zasm_example_memory_operands PROPERTIES
FOLDER
examples
PROJECT_LABEL
memory_operands
RUNTIME_OUTPUT_NAME
example.memory_operands
)
get_directory_property(CMKR_VS_STARTUP_PROJECT DIRECTORY $
{PROJECT_SOURCE_DIR} DEFINITION VS_STARTUP_PROJECT)
if(NOT CMKR_VS_STARTUP_PROJECT)
set_property(DIRECTORY ${PROJECT_SOURCE_DIR} PROPERTY
VS_STARTUP_PROJECT zasm_example_memory_operands)
endif()
endif()
enable_testing()
endif()