diff --git a/.github/actions/spelling/allow.txt b/.github/actions/spelling/allow.txt index 57e1859dc8..cc0c41ee91 100644 --- a/.github/actions/spelling/allow.txt +++ b/.github/actions/spelling/allow.txt @@ -2043,6 +2043,7 @@ endmacro evals primac primaf +primafc cintrf COBJ COBJCON diff --git a/c/CMakeLists.txt b/c/CMakeLists.txt index 947d053eae..d200541062 100644 --- a/c/CMakeLists.txt +++ b/c/CMakeLists.txt @@ -1,19 +1,25 @@ -add_library (primac cintrf.f90 cobyla_c.f90 lincoa_c.f90 bobyqa_c.f90 newuoa_c.f90 uobyqa_c.f90 prima.c) +# Fortran object files must be in a separate library as VS generator does not support mixing C and Fortran +add_library (primafc OBJECT cintrf.f90 cobyla_c.f90 lincoa_c.f90 bobyqa_c.f90 newuoa_c.f90 uobyqa_c.f90) +set_target_properties(primafc PROPERTIES POSITION_INDEPENDENT_CODE ON) +if (NOT BUILD_SHARED_LIBS) + target_link_libraries (primafc INTERFACE ${CMAKE_Fortran_IMPLICIT_LINK_LIBRARIES}) +endif () +target_link_libraries (primafc PUBLIC primaf) # must be PUBLIC for precision macros + +# now the C-only library +add_library (primac prima.c) if (WIN32) set_target_properties(primac PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin) endif() - - target_include_directories (primac PUBLIC $ $ - $) -target_link_libraries (primac PUBLIC primaf) # must be PUBLIC for precision macros + $ + $>) +target_link_libraries (primac PRIVATE primafc) set_target_properties(primac PROPERTIES POSITION_INDEPENDENT_CODE ON C_STANDARD 99) - if (NOT BUILD_SHARED_LIBS) target_compile_definitions(primac PUBLIC PRIMAC_STATIC) - target_link_libraries (primac INTERFACE ${CMAKE_Fortran_IMPLICIT_LINK_LIBRARIES}) endif () # Export symbols on Windows. See more comments in fortran/CMakeLists.txt.