Skip to content

Instantly share code, notes, and snippets.

@cristianadam
Created August 1, 2024 11:50
Show Gist options
  • Save cristianadam/7d2cfcf66af5377e991bade6201dc687 to your computer and use it in GitHub Desktop.
Save cristianadam/7d2cfcf66af5377e991bade6201dc687 to your computer and use it in GitHub Desktop.
configure.cmake
if (CMAKE_ARGC LESS 4)
message("Usage cmake -P " ${CMAKE_ARGV2} " <platform e.g. gcc;cosmo> \"<module;list>\"")
return()
endif()
if(CMAKE_ARGV3 STREQUAL "cosmo")
set(ENV{PATH} $ENV{HOME}/Projects/cosmopolitan/repo/cosmocc/bin:$ENV{PATH})
set(extra_config
--toolchain ${CMAKE_CURRENT_LIST_DIR}/cosmo.cmake
-DQT_HOST_PATH=${CMAKE_CURRENT_LIST_DIR}/install-gcc
-D BUILD_SHARED_LIBS=OFF
-D BUILD_WITH_PCH=OFF
-D QT_FEATURE_gui=OFF
-D QT_FEATURE_library=OFF
-D QT_FEATURE_brotli=OFF
-D QT_FEATURE_getifaddrs=OFF
-D QT_FEATURE_glib=OFF
)
endif()
foreach(module ${CMAKE_ARGV4})
execute_process(COMMAND
${CMAKE_COMMAND} -E time
${CMAKE_COMMAND}
-D "CMAKE_PREFIX_PATH=${CMAKE_CURRENT_LIST_DIR}/install-${CMAKE_ARGV3}"
-D "CMAKE_INSTALL_PREFIX=${CMAKE_CURRENT_LIST_DIR}/install-${CMAKE_ARGV3}"
-G Ninja
-D CMAKE_BUILD_TYPE=Release
-D QT_BUILD_EXAMPLES=OFF
-D QT_BUILD_TESTS=OFF
-D FEATURE_system_zlib=OFF
-D FEATURE_sql_mysql=OFF
-D FEATURE_sql_odbc=OFF
-D FEATURE_sql_psql=OFF
-D FEATURE_system_sqlite=OFF
-D FEATURE_fontconfig=OFF
-D INPUT_harfbuzz=qt
-D INPUT_pcre=qt
-D INPUT_freetype=qt
-D INPUT_libpng=qt
-D INPUT_libjpeg=qt
${extra_config}
-S repo/${module}
-B build-${CMAKE_ARGV3}-${module}
RESULT_VARIABLE result
)
if (NOT result EQUAL 0)
message(FATAL_ERROR "Failed to configure ${module}.")
endif()
execute_process(COMMAND
${CMAKE_COMMAND} -E time
${CMAKE_COMMAND}
--build build-${CMAKE_ARGV3}-${module}
RESULT_VARIABLE result
)
if (NOT result EQUAL 0)
message(FATAL_ERROR "Failed to build ${module}.")
endif()
execute_process(COMMAND
${CMAKE_COMMAND} -E time
${CMAKE_COMMAND}
--install build-${CMAKE_ARGV3}-${module}
RESULT_VARIABLE result
)
if (NOT result EQUAL 0)
message(FATAL_ERROR "Failed to install ${module}.")
endif()
endforeach()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment