diff --git a/.github/workflows/CITest.yml b/.github/workflows/CITest.yml index 42fa37384..b3a5dbde6 100644 --- a/.github/workflows/CITest.yml +++ b/.github/workflows/CITest.yml @@ -91,7 +91,7 @@ jobs: cmake -DCAPSTONE_INSTALL=1 -DCMAKE_INSTALL_PREFIX=/usr -DENABLE_ASAN=${asan} -DCAPSTONE_BUILD_DIET=${diet_build} .. cmake --build . --config Debug # build shared library - cmake -DCAPSTONE_INSTALL=1 -DBUILD_SHARED_LIBS=1 -DCMAKE_INSTALL_PREFIX=/usr -DCAPSTONE_BUILD_CSTEST=ON -DENABLE_ASAN=${asan} .. + cmake -DCAPSTONE_INSTALL=1 -DCAPSTONE_BUILD_SHARED_LIBS=1 -DCMAKE_INSTALL_PREFIX=/usr -DCAPSTONE_BUILD_CSTEST=ON -DENABLE_ASAN=${asan} .. sudo cmake --build . --config Debug --target install - name: Lower number of KASL randomized address bits diff --git a/.github/workflows/clang-tidy.yml b/.github/workflows/clang-tidy.yml index 784825975..44a794ca2 100644 --- a/.github/workflows/clang-tidy.yml +++ b/.github/workflows/clang-tidy.yml @@ -27,7 +27,7 @@ jobs: - name: Build run: | mkdir build && cd build - CC=clang cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DBUILD_SHARED_LIBS=1 .. + CC=clang cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCAPSTONE_BUILD_SHARED_LIBS=1 .. CC=clang sudo cmake --build . --config Release cd .. diff --git a/BUILDING.md b/BUILDING.md index a6d662a85..a5af93da3 100644 --- a/BUILDING.md +++ b/BUILDING.md @@ -67,7 +67,9 @@ without having to compile Capstone multiple times. Capstone allows some more customization via the following options: -- `BUILD_SHARED_LIBS`: Build shared libraries. +- `CAPSTONE_BUILD_SHARED_LIBS`: Build shared libraries. +- `CAPSTONE_BUILD_STATIC_LIBS`: Build static libraries (`ON` by default). +- `CAPSTONE_BUILD_STATIC_MSVC_RUNTIME`: (Windows only) - Build with static MSVC runtime. Always set if `CAPSTONE_BUILD_SHARED_LIBS=ON`. - `CAPSTONE_BUILD_CSTOOL`: Enable/disable build of `cstool`. Default is enabled if build runs from the repository root. - `CAPSTONE_USE_SYS_DYN_MEM`: change this to OFF to use your own dynamic memory management. - `CAPSTONE_BUILD_MACOS_THIN`: MacOS only. Disables universal2 build. So you only get the binary for you processor architecture. diff --git a/CMakeLists.txt b/CMakeLists.txt index e7439379e..714ef12ac 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -54,9 +54,9 @@ endif() # to configure the options specify them in the command line or change them in the cmake UI. # Don't edit the makefile! -option(BUILD_SHARED_LIBS "Build shared library" OFF) -option(BUILD_STATIC_LIBS "Build static library" ON) -option(BUILD_STATIC_RUNTIME "Embed static MSVC runtime (Windows only). Always set if BUILD_SHARED_LIBS=ON" ${BUILD_SHARED_LIBS}) +option(CAPSTONE_BUILD_SHARED_LIBS "Build shared library" OFF) +option(CAPSTONE_BUILD_STATIC_LIBS "Build static library" ON) +option(CAPSTONE_BUILD_STATIC_MSVC_RUNTIME "Embed static MSVC runtime (Windows only). Always set if CAPSTONE_BUILD_SHARED_LIBS=ON" ${CAPSTONE_BUILD_SHARED_LIBS}) option(CAPSTONE_BUILD_MACOS_THIN "Disable universal2 builds on macOS" OFF) option(CAPSTONE_BUILD_DIET "Build diet library" OFF) option(CAPSTONE_BUILD_LEGACY_TESTS "Build legacy tests" ${PROJECT_IS_TOP_LEVEL}) @@ -70,8 +70,8 @@ option(CAPSTONE_INSTALL "Generate install target" ${PROJECT_IS_TOP_LEVEL}) option(ENABLE_ASAN "Enable address sanitizer" OFF) option(ENABLE_COVERAGE "Enable test coverage" OFF) -if (NOT BUILD_SHARED_LIBS AND NOT BUILD_STATIC_LIBS) - FATAL_ERROR("BUILD_SHARED_LIBS and BUILD_STATIC_LIBS are both unset. Nothing to build.") +if (NOT CAPSTONE_BUILD_SHARED_LIBS AND NOT CAPSTONE_BUILD_STATIC_LIBS) + FATAL_ERROR("CAPSTONE_BUILD_SHARED_LIBS and CAPSTONE_BUILD_STATIC_LIBS are both unset. Nothing to build.") endif() if (ENABLE_ASAN) @@ -159,7 +159,7 @@ if(CAPSTONE_DEBUG OR CMAKE_BUILD_TYPE STREQUAL "Debug") endif() # Force static runtime libraries -if(BUILD_STATIC_RUNTIME) +if(CAPSTONE_BUILD_STATIC_MSVC_RUNTIME) set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") endif() @@ -772,7 +772,7 @@ target_include_directories(capstone PUBLIC $ ) -if(BUILD_STATIC_LIBS) +if(CAPSTONE_BUILD_STATIC_LIBS) add_library(capstone_static STATIC $) # Use normal capstone name. Otherwise we get libcapstone_static.a set_target_properties(capstone_static PROPERTIES OUTPUT_NAME "capstone") @@ -781,7 +781,7 @@ if(BUILD_STATIC_LIBS) ) endif() -if(BUILD_SHARED_LIBS) +if(CAPSTONE_BUILD_SHARED_LIBS) set_property(TARGET capstone PROPERTY POSITION_INDEPENDENT_CODE 1) add_library(capstone_shared SHARED $) # Use normal capstone name. Otherwise we get libcapstone_shared.so @@ -898,11 +898,11 @@ if(CAPSTONE_INSTALL) DESTINATION ${CAPSTONE_CMAKE_CONFIG_INSTALL_DIR} ) - if(BUILD_SHARED_LIBS) + if(CAPSTONE_BUILD_SHARED_LIBS) set(LIB_INSTALL_TARGETS capstone_shared) endif() - if (BUILD_STATIC_LIBS) + if (CAPSTONE_BUILD_STATIC_LIBS) set(LIB_INSTALL_TARGETS ${LIB_INSTALL_TARGETS} capstone_static) endif() diff --git a/bindings/python/setup.py b/bindings/python/setup.py index 6dbc83b9b..63f245123 100755 --- a/bindings/python/setup.py +++ b/bindings/python/setup.py @@ -136,12 +136,12 @@ def build_libraries(): print("Build Directory: {}\n".format(os.getcwd())) # Only build capstone.dll / libcapstone.dylib if SYSTEM in ('win32', 'cygwin'): - os.system('cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=ON -DBUILD_STATIC_LIBS=OFF -DCAPSTONE_BUILD_LEGACY_TESTS=OFF -DCAPSTONE_BUILD_CSTOOL=OFF -G "NMake Makefiles" ..') + os.system('cmake -DCMAKE_BUILD_TYPE=Release -DCAPSTONE_BUILD_SHARED_LIBS=ON -DCAPSTONE_BUILD_STATIC_LIBS=OFF -DCAPSTONE_BUILD_LEGACY_TESTS=OFF -DCAPSTONE_BUILD_CSTOOL=OFF -G "NMake Makefiles" ..') elif 'AFL_NOOPT' in os.environ: # build for test_corpus - os.system('cmake -DBUILD_SHARED_LIBS=ON -DCAPSTONE_BUILD_LEGACY_TESTS=OFF -DCAPSTONE_BUILD_CSTOOL=OFF ..') + os.system('cmake -DCAPSTONE_BUILD_SHARED_LIBS=ON -DCAPSTONE_BUILD_LEGACY_TESTS=OFF -DCAPSTONE_BUILD_CSTOOL=OFF ..') else: - os.system('cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=ON -DCAPSTONE_BUILD_LEGACY_TESTS=OFF -DCAPSTONE_BUILD_CSTOOL=OFF -G "Unix Makefiles" ..') + os.system('cmake -DCMAKE_BUILD_TYPE=Release -DCAPSTONE_BUILD_SHARED_LIBS=ON -DCAPSTONE_BUILD_LEGACY_TESTS=OFF -DCAPSTONE_BUILD_CSTOOL=OFF -G "Unix Makefiles" ..') os.system("cmake --build .") shutil.copy(VERSIONED_LIBRARY_FILE, os.path.join(LIBS_DIR, LIBRARY_FILE)) diff --git a/debian/Dockerfile b/debian/Dockerfile index 39d784d43..c3fb4966c 100644 --- a/debian/Dockerfile +++ b/debian/Dockerfile @@ -17,7 +17,7 @@ WORKDIR /capstone/ # Using cmake, see BUILDING.md file # For debug build change "Release" to "Debug" -RUN cmake -B build -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=1 +RUN cmake -B build -DCMAKE_BUILD_TYPE=Release -DCAPSTONE_BUILD_SHARED_LIBS=1 RUN cmake --build build # List files before cmake install