--- CMakeLists.txt.orig	2025-08-30 18:33:06 UTC
+++ CMakeLists.txt
@@ -0,0 +1,75 @@
+cmake_minimum_required(VERSION 3.15)
+
+project(OBUParse VERSION %%DISTVERSION%% LANGUAGES C)
+
+# --- Set Standard Output Directories ---
+set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
+set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
+set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
+
+# --- Build Options ---
+# On MSVC, we only build static to avoid DLL export complexity and naming collisions.
+# On other platforms (including MinGW on Windows), we can build both.
+option(BUILD_SHARED_LIBS "Build the shared library" ON)
+option(BUILD_STATIC_LIBS "Build the static library" OFF)
+
+if(NOT BUILD_SHARED_LIBS AND NOT BUILD_STATIC_LIBS)
+    message(FATAL_ERROR "You must choose to build at least one library type.")
+endif()
+
+# --- Library Targets ---
+
+if(BUILD_SHARED_LIBS) # This block will now be skipped on MSVC
+    add_library(obuparse_shared SHARED obuparse.c)
+    set_target_properties(obuparse_shared PROPERTIES
+        OUTPUT_NAME "obuparse"
+        VERSION ${PROJECT_VERSION}
+        SOVERSION 2
+        EXPORT_NAME "shared"
+    )
+    target_include_directories(obuparse_shared PUBLIC
+        $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
+        $<INSTALL_INTERFACE:include>
+    )
+    add_library(OBUParse::shared ALIAS obuparse_shared)
+endif()
+
+if(BUILD_STATIC_LIBS)
+    add_library(obuparse_static STATIC obuparse.c)
+    # The naming collision only happens with MSVC, not MinGW.
+    if(MSVC)
+        set_target_properties(obuparse_static PROPERTIES OUTPUT_NAME "obuparses")
+    else()
+        set_target_properties(obuparse_static PROPERTIES OUTPUT_NAME "obuparse")
+    endif()
+    set_target_properties(obuparse_static PROPERTIES EXPORT_NAME "static")
+    target_include_directories(obuparse_static PUBLIC
+        $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
+        $<INSTALL_INTERFACE:include>
+    )
+    add_library(OBUParse::static ALIAS obuparse_static)
+endif()
+
+# --- Installation ---
+include(GNUInstallDirs)
+
+# Install the public header file
+install(FILES obuparse.h
+    DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
+)
+
+set(BUILT_TARGETS "")
+if(TARGET obuparse_static)
+    list(APPEND BUILT_TARGETS obuparse_static)
+endif()
+if(TARGET obuparse_shared)
+    list(APPEND BUILT_TARGETS obuparse_shared)
+endif()
+
+# Install the library targets that were built, and the tool
+install(TARGETS ${BUILT_TARGETS}
+    EXPORT OBUParseTargets
+    ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
+    LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
+    RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
+)
