CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Programming & Development

share something about dev of openfoam using cmake rather than wmake

Register Blogs Community New Posts Updated Threads Search

Like Tree6Likes
  • 6 Post By chengdi

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   August 13, 2018, 02:40
Default share something about dev of openfoam using cmake rather than wmake
  #1
Member
 
Di Cheng
Join Date: May 2010
Location: Beijing, China
Posts: 47
Rep Power: 15
chengdi is on a distinguished road
The purpose is take advantage of modern IDEs (VSC, CLion, QT Creator, even Visual Studio with Linux Development Workload) which integrate with cmake better.

wmake is used to do two things:

1. compile OpenFOAM libs: from `src` to `lib*.so`
2. compile applications using OpenFOAM libs: from `xxFoam.C` to `xxFoam`

I only intended to do the second task.

for example: basic/laplacianFoam

add CMakeLists.txt
Code:
cmake_minimum_required (VERSION 3.8)

# cxx11
set( CMAKE_CXX_STANDARD 11 )
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Xlinker --no-as-needed -Xlinker --add-needed")
link_directories($ENV{FOAM_LIBBIN})
add_definitions(-Dlinux64 -DWM_ARCH_OPTION=64 -DWM_DP -DWM_LABEL_SIZE=32 -DNoRepository -m64 -fPIC )

# Make/files
# Add source to this project's executable.
add_executable (laplacianFoam "laplacianFoam.C")

# Make/options
include_directories( $ENV{FOAM_SRC}/finiteVolume/lnInclude )
include_directories( $ENV{FOAM_SRC}/meshTools/lnInclude )
include_directories( $ENV{FOAM_SRC}/OpenFOAM/lnInclude )
include_directories( $ENV{FOAM_SRC}/OSspecific/POSIX/lnInclude )

set(EXTRA_LIBS dl m)
set(LIBS finiteVolume fvOptions meshTools OpenFOAM ${EXTRA_LIBS})

target_link_libraries(laplacianFoam ${LIBS})
I am using vs 2017 to do debug remotely, and intellisense works under proper header sharing settings.

Attached Images
File Type: jpg Capture.jpg (108.3 KB, 199 views)
nsf, msaravia, ajitkumar22 and 3 others like this.
chengdi is offline   Reply With Quote

Old   February 8, 2021, 09:53
Default
  #2
Member
 
Join Date: Feb 2016
Posts: 41
Rep Power: 10
LeeRuns is on a distinguished road
any chance you would share the cmake files?
LeeRuns is offline   Reply With Quote

Old   February 9, 2021, 08:46
Default
  #3
Member
 
Join Date: Feb 2016
Posts: 41
Rep Power: 10
LeeRuns is on a distinguished road
Now I see your cmake files. Nm.
LeeRuns is offline   Reply With Quote

Reply

Tags
cmake, openfoam


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Frequently Asked Questions about Installing OpenFOAM wyldckat OpenFOAM Installation 3 November 14, 2023 11:58
OpenFOAM Training, London, Chicago, Munich, Sep-Oct 2015 cfd.direct OpenFOAM Announcements from Other Sources 2 August 31, 2015 13:36
New OpenFOAM Forum Structure jola OpenFOAM 2 October 19, 2011 06:55
OpenFOAM 1.7.1 installation problem on OpenSUSE 11.3 flakid OpenFOAM Installation 16 December 28, 2010 08:48
Can anybody help me to solve the list errors while compiling Openfoam 15 on Opensuse 103 32bit coompressor OpenFOAM Installation 0 November 12, 2008 19:53


All times are GMT -4. The time now is 14:08.