Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Beginner
56 Views

How to let Intel Fortran link objects to static library?

Dear all,

I am trying to write CMakeLists.txt to let CMake to generate C++ and Fortran projects. Because I need to build both static and dynamic libraries, I need to build objects at first, and then link them to static and dynamic libraries. The CMake code to generate projects is as follows:

Code to generate static library by 'OBJECT' keyword of CMake:

 

	ADD_LIBRARY(MUMPS_d_FORTRAN OBJECT
							"${MUMPS_COMMON_OTHER_HEAD}" 
							"${dMUMPS_SRC}"
							"${dMUMPS_OTHER_SRC}")
								
	SET_TARGET_PROPERTIES(MUMPS_d_FORTRAN PROPERTIES
							COMPILE_FLAGS "${GENERIC_COMPILER_FLAGS_FORTRAN} ${ORDERINGS_COMPILER_FLAGS_FORTRAN} -c"
							LINKER_LANGUAGE FORTRAN)
				
	TARGET_INCLUDE_DIRECTORIES(MUMPS_d_FORTRAN PUBLIC
							"${MUMPS_INCLUDE_DIRS}"
							"${LIBSEQ_INCLUDE_DIRS}") 

 

 

code to generate static library by objects:

		ADD_LIBRARY(dmumps STATIC
								$<TARGET_OBJECTS:MUMPS_d_FORTRAN>)
		SET_TARGET_PROPERTIES(dmumps PROPERTIES
								COMPILE_FLAGS "${GENERIC_COMPILER_FLAGS_FORTRAN} ${ORDERINGS_COMPILER_FLAGS_FORTRAN} -c"
								LINKER_LANGUAGE C)
		
		TARGET_INCLUDE_DIRECTORIES("dmumps" PUBLIC
								"${MUMPS_INCLUDE_DIRS}"
								"${LIBSEQ_INCLUDE_DIRS}")

 

Now the problem is that when I build the whole solution, the project 'MUMPS_d_FORTRAN' can successfully generate MUMPS_d_FORTRAN.lib but the project 'dmumps' generated nothing. What could lead to this problem.

I tested both VS2013 + Intel Parallel Studio 2016 update 2 and VS2015 + Intel Parallel Studio 2017 update 4 and the results are the same.

PS: I have similar operation for C++ project, but both projects can successfully generate static libraries.

Thanks,

Tang Laoya

 

 

0 Kudos
2 Replies
Highlighted
Beginner
56 Views

Another problem: I am trying to let CMake set the Runtime library (Project->Properties->Configuration Properties->Fortran->Libraries) to Multithreaded (change from default value Multithreaded DLL) by the following command:

set(CMAKE_FORTRAN_FLAGS_DEBUG "/MTd ${CMAKE_FORTRAN_FLAGS_DEBUG}")
set(CMAKE_FORTRAN_FLAGS_RELEASE "/MT ${CMAKE_FORTRAN_FLAGS_RELEASE}")

or the following command:

set (DBUILD_WITH_STATIC_CRT "OFF")

But they all don't work. Could anyone tell me how to write code to do these settings?

Thanks,

Tang Laoya

0 Kudos
Highlighted
Black Belt
56 Views

Your questions have more to do with Cmake than the Intel Fortran compiler, and you would probably receive help on your question if you ask in a Cmake forum or ask the authors of the Cmakefile.txt that you are using.

If you have got as far as getting Cmake to produce a makefile, and you ran into problems using that makefile, you can report here the problems that you ran into with the makefile.

0 Kudos