beginner: questions about CMake

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

beginner: questions about CMake

tang
This post has NOT been accepted by the mailing list yet.
Dear all,

I need to use CMake file to generate projects used by VS2015+Intel Fortran 2017 in Windows 7 64bit system. I have three questions about using CMake:
1) how can I generate projects to link objects by Fortran sources into a static library?
The following code can generate two VF projects, the project 'libseq_fortran' works, it can generate 'libseq_fortran.lib', but the second 'libseq' do nothing when build the solution in VS2015.
ADD_LIBRARY(libseq_fortran OBJECT
                                                ${LIBSEQ_SRC_FORTRAN}
                                                ${LIBSEQ_HEAD_FORTRAN})

SET_TARGET_PROPERTIES(libseq_fortran PROPERTIES
                                                COMPILE_FLAGS "${GENERIC_COMPILER_FLAGS_FORTRAN} -c"
                                                COMPILE_DEFINITIONS "${COMPILER_DEFS_FORTRAN}"
                                                LINKER_LANGUAGE FORTRAN)

ADD_LIBRARY(libseq STATIC
                                                $<TARGET_OBJECTS:libseq_fortran>)
SET_TARGET_PROPERTIES(libseq PROPERTIES
                                                LINKER_LANGUAGE FORTRAN)


2) how can I let the project output static library to the given folders, for example, when in Debug mode, I wish the static libraries be outputted to
${CMAKE_SOURCE_DIR}/../LIB/DEBUG
and when in Release mode, I wish the static libraries be outputted to
${CMAKE_SOURCE_DIR}/../LIB/RELEASE

I tried to add these two command in CMakelists.txt:
SET(ARCHIVE_OUTPUT_DIRECTORY_DEBUG "${CMAKE_SOURCE_DIR}/../LIB/DEBUG")
SET(ARCHIVE_OUTPUT_DIRECTORY_RELEASE "${CMAKE_SOURCE_DIR}/../LIB/RELEASE")

but it doesn't work, all libs are put there own folders.


3) how to let the Fortran code compiled by 'Multithreaded' instead of 'Multithread DLL'? I used the following command but it doesn't work:
set(CMAKE_Fortran_FLAGS "/libs:static /threads ${CMAKE_Fortran_FLAGS}")


Thanks,
Tang Laoya
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: beginner: questions about CMake

tang
This post has NOT been accepted by the mailing list yet.
Dear all,

For my second question, I put the following command lines to the beginning of CMakelist.txt (after project name):

SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_DEBUG "${CMAKE_SOURCE_DIR}/LIB64/DEBUG")
SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG "${CMAKE_SOURCE_DIR}/LIB64/DEBUG")
SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY_DEBUG "${CMAKE_SOURCE_DIR}/LIB64/DEBUG")
SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE "${CMAKE_SOURCE_DIR}/LIB64/RELEASE")
SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE "${CMAKE_SOURCE_DIR}/LIB64/RELEASE")
SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE "${CMAKE_SOURCE_DIR}/LIB64/RELEASE")

after generated projects and build the solution by VS2015, I found that all static libraries generated by C projects are put in correct folder, but all static libraries by Fortran projects are still put in their own folders. Could anyone tell me what other variables should I set?

Thanks,
Tang Laoya
Loading...