diff --git a/common/pgm_base.cpp b/common/pgm_base.cpp index eccf0fb5f0..d852571e0a 100644 --- a/common/pgm_base.cpp +++ b/common/pgm_base.cpp @@ -550,10 +550,14 @@ bool PGM_BASE::InitPgm( bool aHeadless, bool aSkipPyInit, bool aIsUnitTest ) SetDefaultLanguage( tmp ); #ifdef _MSC_VER - // We need to set this because the internal fontconfig logic - // seems to search relative to the dll rather the other logic it - // has to look for the /etc folder above the dll - wxSetEnv( "FONTCONFIG_PATH", PATHS::GetWindowsFontConfigDir() ); + if( !wxGetEnv( "FONTCONFIG_PATH", NULL ) ) + { + // We need to set this because the internal fontconfig logic + // seems to search relative to the dll rather the other logic it + // has to look for the /etc folder above the dll + // Also don't set it because we need it in QA cli tests to be set by ctest + wxSetEnv( "FONTCONFIG_PATH", PATHS::GetWindowsFontConfigDir() ); + } #endif m_settings_manager = std::make_unique( aHeadless ); diff --git a/qa/CMakeLists.txt b/qa/CMakeLists.txt index c28ce5b842..2cd251a39a 100644 --- a/qa/CMakeLists.txt +++ b/qa/CMakeLists.txt @@ -21,6 +21,25 @@ include( KiCadQABuildUtils ) +macro(setup_qa_env target_name) +if( MSVC ) + # Once we move the cmake minimum to 3.22, we can use this for all platforms and not just MSVC + # the old method only worked on MSVC due to a bug in cmake which was later fixed after ENVIRONMENT_MODIFICATION was added + set( PATH_MODIFICATION + "PATH=path_list_prepend:${VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/debug/bin" + "PATH=path_list_prepend:${CMAKE_BINARY_DIR}/kicad/" + "PATH=path_list_prepend:${CMAKE_BINARY_DIR}/common/" + "PATH=path_list_prepend:${CMAKE_BINARY_DIR}/api/" + "PATH=path_list_prepend:${CMAKE_BINARY_DIR}/common/gal/" + "PATH=path_list_prepend:${CMAKE_BINARY_DIR}/pcbnew/" + "PATH=path_list_prepend:${CMAKE_BINARY_DIR}/eeschema/" ) + set_tests_properties( ${target_name} + PROPERTIES + ENVIRONMENT_MODIFICATION "${PATH_MODIFICATION}" + ) +endif() +endmacro() + # Shared QA helper libraries add_subdirectory( qa_utils ) add_subdirectory( pcbnew_utils ) diff --git a/qa/resources/windows/fonts/fonts.conf b/qa/resources/windows/fonts/fonts.conf new file mode 100644 index 0000000000..c8fdfc24e4 --- /dev/null +++ b/qa/resources/windows/fonts/fonts.conf @@ -0,0 +1,103 @@ + + + + + Default configuration file + + + + + + WINDOWSFONTDIR + WINDOWSUSERFONTDIR + + + fonts + + ~/.fonts + + + + + mono + + + monospace + + + + + + + sans serif + + + sans-serif + + + + + + + sans + + + sans-serif + + + + + + system ui + + + system-ui + + + + + conf.d + + + + LOCAL_APPDATA_FONTCONFIG_CACHE + fontconfig + + ~/.fontconfig + + + + + 30 + + + + diff --git a/qa/tests/CMakeLists.txt b/qa/tests/CMakeLists.txt index 05424f1937..54e101da22 100644 --- a/qa/tests/CMakeLists.txt +++ b/qa/tests/CMakeLists.txt @@ -57,15 +57,19 @@ ${NEW_PATHS};" ) get_filename_component( CAIRO_LIB_BASE "${CAIRO_LIBRARY}" DIRECTORY ) set( EXTRA_PYTEST_ENVIRONMENT "DYLD_FALLBACK_LIBRARY_PATH=${CAIRO_LIB_BASE}" ) elseif ( MSVC ) + + if( CMAKE_BUILD_TYPE STREQUAL "Debug" ) set( NEW_PATHS "${VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/debug/bin;\ - ${NEW_PATHS};" ) +${NEW_PATHS};" ) else() set( NEW_PATHS "${VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/bin;\ - ${NEW_PATHS};" ) +${NEW_PATHS};" ) endif() + + set( EXTRA_PYTEST_ENVIRONMENT "FONTCONFIG_PATH=${CMAKE_SOURCE_DIR}/qa/resources/windows/fonts/" ) endif() set( QA_PATH_REPLACEMENT "PATH=${NEW_PATHS};$ENV{PATH}" ) @@ -94,7 +98,16 @@ add_test(NAME qa_cli WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} ) -set_tests_properties( qa_cli - PROPERTIES - ENVIRONMENT "${QA_PATH_REPLACEMENT};KICAD_RUN_FROM_BUILD_DIR=1;PYTHONPATH=${CMAKE_BINARY_DIR}/pcbnew;${PYTHON_QA_PATH};${EXTRA_PYTEST_ENVIRONMENT}" -) +if( NOT MSVC ) + set_tests_properties( qa_cli + PROPERTIES + ENVIRONMENT "${QA_PATH_REPLACEMENT};KICAD_RUN_FROM_BUILD_DIR=1;PYTHONPATH=${CMAKE_BINARY_DIR}/pcbnew;${PYTHON_QA_PATH};${EXTRA_PYTEST_ENVIRONMENT}" + ) +else() + set_tests_properties( qa_cli + PROPERTIES + ENVIRONMENT "KICAD_RUN_FROM_BUILD_DIR=1;PYTHONPATH=${CMAKE_BINARY_DIR}/pcbnew;${PYTHON_QA_PATH};${EXTRA_PYTEST_ENVIRONMENT}" + ) + + setup_qa_env( qa_cli ) +endif() diff --git a/qa/tests/api/CMakeLists.txt b/qa/tests/api/CMakeLists.txt index 841193a2b5..4b62a757d1 100644 --- a/qa/tests/api/CMakeLists.txt +++ b/qa/tests/api/CMakeLists.txt @@ -57,3 +57,5 @@ target_include_directories( qa_api PRIVATE ) kicad_add_boost_test( qa_api qa_api ) + +setup_qa_env( qa_api ) \ No newline at end of file diff --git a/qa/tests/common/CMakeLists.txt b/qa/tests/common/CMakeLists.txt index 2c3cabf860..17440dd04f 100644 --- a/qa/tests/common/CMakeLists.txt +++ b/qa/tests/common/CMakeLists.txt @@ -116,3 +116,5 @@ if( KICAD_TEST_DATABASE_LIBRARIES ) endif() kicad_add_boost_test( qa_common qa_common ) + +setup_qa_env( qa_common ) \ No newline at end of file diff --git a/qa/tests/eeschema/CMakeLists.txt b/qa/tests/eeschema/CMakeLists.txt index e4095f6b40..8bc9ce02df 100644 --- a/qa/tests/eeschema/CMakeLists.txt +++ b/qa/tests/eeschema/CMakeLists.txt @@ -123,3 +123,5 @@ target_compile_definitions( qa_eeschema ) kicad_add_boost_test( qa_eeschema qa_eeschema ) + +setup_qa_env( qa_eeschema ) \ No newline at end of file diff --git a/qa/tests/gerbview/CMakeLists.txt b/qa/tests/gerbview/CMakeLists.txt index 8a1b0442c3..004b3d43f5 100644 --- a/qa/tests/gerbview/CMakeLists.txt +++ b/qa/tests/gerbview/CMakeLists.txt @@ -75,3 +75,5 @@ target_link_libraries( qa_gerbview ) kicad_add_boost_test( qa_gerbview qa_gerbview ) + +setup_qa_env( qa_gerbview ) \ No newline at end of file diff --git a/qa/tests/libs/kimath/CMakeLists.txt b/qa/tests/libs/kimath/CMakeLists.txt index 4aa7cd2b27..237518f00c 100644 --- a/qa/tests/libs/kimath/CMakeLists.txt +++ b/qa/tests/libs/kimath/CMakeLists.txt @@ -89,3 +89,5 @@ target_include_directories( qa_kimath PRIVATE ) kicad_add_boost_test( qa_kimath qa_kimath ) + +setup_qa_env( qa_kimath ) \ No newline at end of file diff --git a/qa/tests/pcbnew/CMakeLists.txt b/qa/tests/pcbnew/CMakeLists.txt index 122d4ad981..2e17855b7c 100644 --- a/qa/tests/pcbnew/CMakeLists.txt +++ b/qa/tests/pcbnew/CMakeLists.txt @@ -150,3 +150,5 @@ if( WIN32 ) endif() kicad_add_boost_test( qa_pcbnew qa_pcbnew ) + +setup_qa_env( qa_pcbnew )